Git cheat-sheet for the summer

A few commands that might come in handy this summer. (The list will increase as I grow older):

$ ### Configure Git
$ git config --global user.name "Sarup Banskota"
$ git config --global user.email 911@someplace.com
$ git config --global color.ui true

$ ### Commit without staging files
$ git commit -am "Commit message"

$ ### Undo last commit and shift to staging
$ git reset --soft HEAD^
$ ### Undo last commit and blow away everything
$ git reset --hard HEAD^

$ ### Add some more to last commit
$ git commit --amend -m "Overwrite message"

$ ### Check differences since last stage
$ git diff

$ ### Check differences as the stage changes 
$ git diff --staged

$ ### Unstage a file that was added
$ git reset HEAD filename

$ ### To completely remove all new changes to a file
$ git checkout --filename.txt

$ ### Adding a remote repo to a host
$ git remote add <name> <URL>
$ ### Removing a remote
$ git remote -rm <name>

$ ### Push to a remote repo
$ git push -u <name> <branch name> #first time

$ ### Remove a remote branch
$ git push origin :branchname

$ ### See branches in a remote
$ git remote show origin

$ ### See all tags
$ git tag
$ ### Jump to one of those tags
$ git tag tagname
$ ### Add a new tag
$ git tag -a tagname -m "description"
$ ### Pushing new tags
$ git push --tags

$ ### Clean stale remote branches to a parent branch
$ git remote prune branchname

Advertisements

2 thoughts on “Git cheat-sheet for the summer

  1. Pingback: Imaginiti | December and Scrapy

  2. Pingback: Rails adventure and the last week – some more desi cola

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s