Last active
May 2, 2022 15:45
-
-
Save ospatil/7eea454c11d25e86c7ca76a03efed6f7 to your computer and use it in GitHub Desktop.
Important git command for branch and tag management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. get list of remote tags | |
git ls-remote --tags origin | |
2. get list of local tags | |
git tag | |
3. remove local tag | |
git tag -d <tag name> | |
4. delete remote tag | |
git push origin :<tag name> | |
5. show all branches | |
git branch -a | |
6. show only remote branches | |
git branch -r | |
7. delete local branch | |
git branch -d the_local_branch | |
8. delete remote branch | |
git push origin --delete <branchName> | |
9. resetting a branch to specific commit | |
git reset --hard <commit-hash> | |
10. to revert n commits | |
git reset --hard HEAD~n-1 | |
git push -f origin <branch-name> | |
11. Cleaning untracked files from a branch - | |
(Just show what will be deleted) git clean -fn | |
(Actually delete) git clean -f | |
(to remove directories also) git clean -fd | |
12. Tagging a particular older commit in git - | |
git tag -a v1.2 9fceb02 -m "Message here" | |
13. Easiest release process on github - | |
npm version [version or version token such as minor, patch etc.] | |
git push origin --tags | |
git push origin master | |
npm publish | |
14. Squash several commits into one - | |
http://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit | |
15. Create a branch with the tag | |
git branch {tagname}-branch {tagname} | |
git checkout {tagname}-branch | |
16. Include the fix manually if it's just a change .... | |
git add . | |
git commit -m "message" | |
17. Delete and recreate the tag locally | |
git tag -d {tagname} | |
git tag {tagname} | |
18. Delete and recreate the tag remotely | |
git push origin :{tagname} // deletes original remote tag | |
git push origin {tagname} // creates new remote tag | |
(15, 16, 17 and 18 thanks to https://gist.github.com/danielestevez/2044589) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment