Git advanced command


1: View the submission history

git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'

Rank the local shares in the GIT commit submission order. You can use this command to delete some parts that have not been used for a long time.

2: Flattening merge

git merge --squash

In fact, it is still very useful. In GitHub, gitee and other code hosting websites, I generally use flat merging for PR merging


Tag push and half push are two different things. Pushing one third to origin does not mean that the tag is also pushed.

Git tag // list all tags
Git tag v0.0.4 // create a local tag easily
Git push origin -- tags // push tag to origin

Git tag - d < tagName > // delete local tag
Git push origin: < tagName > // Delete remote Tag

4: Git ignores files that have been submitted to the version library

Take the. Idea folder as an example

//Folder needs to add - R
git rm -r --cached .idea/
git commit -m 'git ignore'

5: Basic command

Git help // this is basically comprehensive
git config --list
git remote -v

6: Merge multiple commits

//The following command indicates the commit after merging 6f9b8ecc (excluding 6f9b8ecc)
git rebase -i 6f9b8ecc
//Merge into two submissions
git rebase -i HEAD~2

Git advanced command

Change pick to s save and exit, and then confirm to save and exit the submitted content

Git advanced command