Skip to content

Instantly share code, notes, and snippets.

@GromNaN
Created December 15, 2011 08:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GromNaN/1480288 to your computer and use it in GitHub Desktop.
Save GromNaN/1480288 to your computer and use it in GitHub Desktop.
My Git Commands

Initialize a repository without working directory

git init --bare --shared=0700

Undo last commit

git reset --hard HEAD~1

Review changes going to be committed

git diff --cached <file>

Reset to remote history

git reset --hard origin/<branch>

Duplicate a commit to an other branch

git cherry-pick <commit>

Backup current workspace (useful before rebase)

git stash

Restore last stash

git stash apply

Amend previous commit

git rebase <commit-hash>^ --interactive
# Replace "pick" with "edit" for commits to modify

git add <files>
git commit --amend
git rebase --continue

Using GIT-SVN

git svn clone -s SVN_REPO_URL LOCAL_DIR
git checkout -b my_branch

git checkout master
git svn rebase

git checkout my_branch
git rebase master

git svn dcommit

Git configuration

Ignore CHMOD modifications

git config --global core.filemode false

Enable colors

git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto

Alias

git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.df 'diff'
git config --global alias.dfc 'diff --cached'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment