Record daily git commands

git add -A adds all modifications and deletions of tracked files and new untracked files to the staging area
git add. Adds all code modified in the current directory from the workspace to the staging area. Represents Current directory - does not process deleted files.
git status checks the difference between the workspace code and the staging area.
git commit -m "Submission content description". The submission content can be feat (commonly used), fix (commonly used), docs, style, etc. Examples at the beginning
: feat (coupon): Complete the background coupon function
git push origin branch name and push to the remote branch
git push origin test:master // Submit the local test branch as the remote master branch

git checkout branch name switch branch
git checkout -b branch name create + switch branch
git checkout --help view help

git log View commit records
git branch View all existing local branches
git branch -r View remote repository branch list
git branch -a View all branch lists, including local and remote
git branch -d branch name Delete branch
git branch -D branch force delete branch name
git push origin --delete branch name delete remote branch (use with caution)

git fetch updates the remote code to the local, but does not merge
the git merge merge code
git pull origin branch name is equivalent to git fetch and git merge, that is, updates the code of the remote warehouse to the local warehouse, and then merges the content into the current branch
git rebase origin/master Rebase will put the commit of your current branch at the end of the public branch, so it is called rebase, while merge is a merge.

Merge multiple commit operations:
1. git rebase -i HEAD~4 to merge the last 4 commits
2. Modify the pick in the last few commit records to squash
3. Save and exit, pop up the modified file, modify the commit record and save and exit again (delete the redundant ones) Only one change-id is retained)
4 git add .
5 git rebase --continue

git reset --hard version number rollback version
git reset – soft version number rollback commit

Version (tag) operation related commands
git tag View version
git tag tag name Create version
git push origin tag name Create remote version (local version pushed to remote)
git push origin --tags If there are many unpushed local tags, push them all at once tags
git push origin:refs/tags/tagname Delete the remote version
git tag -d /tagname Delete the local version

Guess you like

Origin blog.csdn.net/qq_37174991/article/details/120666966