You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# last commit
git reset --hard HEAD^
# last 2 commits
git reset --hard HEAD~2
rework last commit
git reset HEAD^
delete branch
# remove the local branch
git branch -d the_local_branch
# To remove a remote branch (if you know what you are doing!)
git push origin :the_remote_branch
# Or simply use the new syntax (v1.7.0)
git push origin -d the_remote_branch
# add
git tag 12345
git push --tags
# remove
git tag -d 12345
git push origin :refs/tags/12345
# Or simply use the new syntax (v1.7.0)
git push origin -d 12345
submodules
add submodule
git submodule add -b master https://github.com/project/trackchanges.git path/to/trackchanges
# after cloning the main repo:
git submodule update --init
git submodule update --remote
remove submodule
0. mv a/submodule a/submodule_tmp
1. git submodule deinit -f -- a/submodule
2. rm -rf .git/modules/a/submodule
3. git rm -f a/submodule
# Note: a/submodule (no trailing slash)
# or, if you want to leave it in your working tree and have done step 0
3. git rm --cached a/submodule
3bis mv a/submodule_tmp a/submodule
utils
# To count the commits for the branch you are on:
git rev-list --count HEAD
# for a branch
git rev-list --count <branch-name>
# If you want to count the commits on a branch that are made since you created the branch
git rev-list --count HEAD ^<branch-name>