How To List All Tags With The Message In git
1 2 |
git tag -n git tag -n3 |
To update your git user name and email address for all repos:
1 2 |
git config --global user.name "Your Name" git config --global user.email "yourName@theDomain.com" |
To update your git user name and email address for a specific repo:
1 2 3 |
cd repo git config user.name "Your Name" git config user.email "yourName@theDomain.com" |
shell> git merge branch-with-messy-changes
1 2 3 |
Auto-merging myCode.pm CONFLICT (content): Merge conflict in myCode.pm Automatic merge failed; fix conflicts and then commit the result. |
shell> git status
1 2 3 4 5 6 7 8 9 10 11 12 13 |
On branch eric-merge Your branch is up to date with 'origin/eric-merge'. You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Changes to be committed: Unmerged paths: (use "git add <file>..." to mark resolution) both modified: myCode.pm |
1 2 |
shell> git merge --abort shell> git status |
1 2 3 4 |
On branch eric-merge Your branch is up to date with 'origin/eric-merge'. nothing to commit, working tree clean |
IMPORTANT NOTE: Previous versions of git used different commands for this operation: Latest version: git merge –abort Older than version 1.7.4: git reset –merge Older than version 1.6.2: git reset –hard
Recent changes to git have made the push default choice a bit confusing – “matching” vs. “simple” I picked “matching” when prompted. This means that git push by itself will try to push ALL local branches, not just the one you are working on. Personally, I find that a bit mad, so I decided to […]
To revert the local branch:
1 |
$ git reset --hard HEAD~1 |
To revert the remote branch AFTER the previous step has been performed:
1 |
$ git push origin HEAD --force |
Show All Branches, Local and Remote
1 |
git branch -a |
Show Local Branches
1 |
git branch |
Show Remote Branches
1 |
git branch -r |
To fetch all remote branches locally
1 2 3 |
git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done git fetch --all git pull --all |
For more information about Tagging in GIT, please visit: https://git-scm.com/book/en/v2/Git-Basics-Tagging Add an Annotated Tag:
1 2 |
git tag -a v1.0.0 -m "Software version 1.0.0" git show v1.0.0 |
Add a Lightweight Tag:
1 2 |
git tag v1.0.1 git show v1.0.1 |
Show all tags:
1 |
git tag |
Push all tags:
1 |
git push origin --tags |
Add a Tag Later:
1 2 3 4 5 6 7 8 9 10 11 12 |
git log --pretty=oneline git tag v1.0.2 5370c8da4095fefad7476fa1c226a309dd00a9f7 git tag -a v1.0.2 5370c8da4095fefad7476fa1c226a309dd00a9f7 fatal: tag 'v1.0.2' already exists git tag -d v1.0.2 Deleted tag 'v1.0.2' (was 5370c8d) git tag -a v1.0.2 5370c8da4095fefad7476fa1c226a309dd00a9f7 git push origin --tags |
Use a Tag:
1 2 |
git checkout -b {new branch name} {tag name} git checkout -b v1.0.2-from-tag v1.0.2 |
shell$ git log | head -1 commit a203e1bd04718bff10a3df4a3389c493c97c0432 Use the commit string as the last argument to the git revert command: shell$ git revert -m 1 a203e1bd04718bff10a3df4a3389c493c97c0432
Show commits and messages that match
1 |
git log --all --grep='SEARCH_STRING_HERE' |
Include code diffs
1 |
git log --all --grep='SEARCH_STRING_HERE' -p |
Include file names
1 |
git log --all --grep='SEARCH_STRING_HERE' --name-only |
1 |
git log --pickaxe-regex -p --color-words -S "theSearchString" |