Skip to content

Instantly share code, notes, and snippets.

@andywenk
Created November 17, 2009 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andywenk/236796 to your computer and use it in GitHub Desktop.
Save andywenk/236796 to your computer and use it in GitHub Desktop.

Some simple git commands

Andy Wenk - 17.11.2009

This is the second part of some notes to myself concerning git. Let's first have a look to some basic commands

basic commands


actualize the repo $ git pull

show the status of the repo $ git status

add the changes to the repo $ git commit changed-files

see the changes $ git log changed-file

move all changes made in a branch to master $ git checkout master $ git merge changed-file-from-my-branch

revert changes


Changes made to files sometimes have to be reverted.

revert the changes made to the repo using the commit id $ git revert 3c15fa6687dbecad7bced5c3d0f4130894bc17e4

revert (after commit) alternatively to HEAD $ git revert HEAD

revert all changes bevor a commit $ git reset --hard HEAD

revert only changes made to a specific file (first overwrite the changed file with the one in the remote repo and then move it to HEAD) $ git checkout -- changed-file $ git checkout HEAD changed-file

branch commands


Now some commands related to bramnches

create a branch $ git branch postgresql-aw

see all branches $ git branch -a

delete a branch $ git branch -d postgresql-aw

create a branch and get all updates from master $ git branch --track postgresql-aw

change to the branch $ git checkout postgresql-aw

create a patch


$ git format-patch origin/master

With these commands, it should be easy to start with git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment