Skip to main content

1. Create and merge branch

Git encourages heavy use of branches:

View the branch: git branch

Create a branch: git branch <name>

Switch branches: git checkout <name> or git switch <name>

Create + switch branches: git checkout -b <name> or git switch -c <name>

Merge a branch into the current branch: git merge <name>

Delete a branch: git branch -d <name>

See the merge status of the branch: git log --graph --pretty=oneline --abbrev-commit

img

2. Bug branch

git stash

View - git stash list

git stash pop = git stash apply + git stash drop

img

3. Git tag

The command git tag <tagname>is used to create a new tag, the default is HEAD, and you can also specify a commit id;

Commands git tag -a <tagname> -m "blablabla..."can specify tag information;

Command git tag to view all tags.

The command git push origin <tagname>can push a local tag;

The commandgit push origin --tagscan push all local tags that have not been pushed;

The command git tag -d <tag name> can delete a local tag;

Command git push origin :refs/tags/<tagname> to delete a remote tag.