• The purpose of this article is to review Git because git operations are quite important. Although there are not many operations in daily use, they are still quite important

1, start

1. Distributed

2. Be independent

3, the installation of direct official website is not talked about

4, processes,

2. Common commands

Git add. Git commit -m 'XXX' git push -b 'XXX' git push -b 'XXX' git push -b 'XXX' git push -b 'XXX' git push -b 'XXX' git push Git reflog -- check -- file git reflog -- check -- file git reflog -- check -- file Git checkout -- test.txt git rm test. TXT git commit -m "remove test.txt"Copy the code

3. Talk about branch management

1. Display of common branch strategies

 git checkout -b dev
Switched to a new branch 'dev'

Copy the code
git branch
* dev
  master
Copy the code
  • It needs to be merged into master when dev development is complete
git merge dev
Copy the code
  • Then delete the development branch
Git branch -d dev (Forcibly Deleted) Git branch -d dev Deleted branch dev (was B17d20e).Copy the code
  • And when you look at it, you’re just left with the master
git branch
* master
Copy the code

2. There is a second way to create and switch branches

Check out the branch: Git Branch

Git branch

Git checkout

Git checkout -b

Git merge

Git branch -d

3. There is a choice to be made about conflict

Git log --graph git log --graphCopy the code

4. New bug branch

1, but the current development branch content modified half of the bug how to deal with? Git checkout -b bug-fixed is the branch where you want to create a bug 4, How to restore the git stash stash stash? Git stash list 1, git stash apply + git stash drop If you want to restore the stash list, use 'git Stash list' first and then restore the specified stash.  git stash apply stash@{0}Copy the code

5. Push branches

Git push origin branch dev = git push origin branch dev = git push origin branch dev = git push origin branch dev = git push origin branch dev Git branch -b branch-name origin/branch-name = branch-name = branch-name - Use git branch --set-upstream branch-name origin/branch-name to establish a connection between a local branch and a remote branch. - Grab branches from a remote location, using Git pull. If there are conflicts, handle them firstCopy the code

6. Rebase

Git rebase displays multiple commits as a single lineCopy the code

7. Tag

$git branch * dev master $git checkout master Switched to branch 'master Git log --pretty=oneline --abbrev-commit git tag v1.0 git tag v1.0 V0.9f52c633 git show <tagname> - 'git push origin --tags' can push all unpushed local tags; Git tag -d <tagname> can be used to delete a local tag. - The 'git push origin :refs/tags/<tagname>' command can remove a remote tagCopy the code

4. What if something goes wrong

1) create a branch (XXX) on your master branch (321). 2) create a branch (XXX) on your master branch (321) Master 4, git pull 5, git checkout -b XXX git push 6Copy the code