Skip to content

Instantly share code, notes, and snippets.

@amitmerchant1990
Last active August 31, 2016 12:50
Show Gist options
  • Save amitmerchant1990/0ecafae25b5d408d04d1f675b78d7b4e to your computer and use it in GitHub Desktop.
Save amitmerchant1990/0ecafae25b5d408d04d1f675b78d7b4e to your computer and use it in GitHub Desktop.
git-ingredients
git install on ubuntu
sudo apt-get install git

point your local repository to remote repository

git remote add origin git@....repo_url

set user config

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

set alias for git command

git config --global alias.co checkout

GUI tool

gitg (can install : sudo apt-get install gitg)

merge tool

apt-get install meld

configure merge tool

git config --global merge.tool meld

See uncommited changes diffrence

git difftool

Undo changes.

git checkout . - Removes Unstaged Tracked files ONLY
git clean -f - Removes Unstaged UnTracked files ONLY
git reset --hard - Removes Staged Tracked and UnStaged Tracked files ONLY
git stash -u - Removes all changes

save uncommited changes

git stash
git stash pop
git stash apply

append to previous commit

git commit --amend

Rebase (Read more about rebase)

git rebase -i branch

Rollback commit

git reset --soft HEAD^
git reset --hard HEAD^
git reset --hard HEAD^^

Restore commit

git reset --hard f6e5064

or

git reset HEAD@{1}

Reference log

git reflog show

Generate patch file

git format-patch HEAD~
git apply --stat fix_empty_poster.patch
git apply --check fix_empty_poster.patch
git am --signoff < fix_empty_poster.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment