Skip to content

Instantly share code, notes, and snippets.

@nickarthur
Forked from guilhermewop/git-useful-commands.sh
Created April 29, 2018 03:43
Show Gist options
  • Save nickarthur/40084207e41df1980cc00f90dd6da732 to your computer and use it in GitHub Desktop.
Save nickarthur/40084207e41df1980cc00f90dd6da732 to your computer and use it in GitHub Desktop.
Git commands
# Removing a branch
Local : git branch -D <branch>
Remote : git push origin :<branch>
#---------------------------
# Rename commit message
# ref: http://darrinholst.com/post/359817782
git rebase -i <commit-hash>
#---------------------------
# Rename branch
git branch -m <old_branch> <new_branch>
#---------------------------
# Keeping a clean GitHub fork.
# Ref: http://blog.evan.pro/keeping-a-clean-github-fork-part-1
git remote add upstream <git-url-project>
git fetch upstream
git merge --ff-only upstream/master
git pull --ff-only upstream master
git push origin master
git fetch --all
#---------------------------
# Properly excluding IDE-specific files with Git
# Ref: http://blog.evan.pro/properly-excluding-ide-specific-files-with-git
git config --global core.excludesfile ~/.gitignore_global
#---------------------------
# Rename a tag
git tag new_tag old_tag
git push --tags
git push origin :refs/tags/old_tag
git tag -d old_tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment