Tech Blog :: Drupal Dojo 9/29: Git workflows


Sep 29 '10 8:57pm
Tags

Drupal Dojo 9/29: Git workflows

Learned tonight at the unofficial Drupal Dojo in JP (copied from BHirsch):

Helpful links about forking (w github)
http://help.github.com/forking/
http://help.github.com/pull-requests/

Undo a local change to a specific file do:
(note this checkout trick only works with modified files, not new files)
$ git checkout filename
OR
$ git checkout path/to/file

Note: -- (double dash) separates all your options from the file path. E.g...
$ git command op1 op2 op3 -- path/to/file

Undo a committed change to a single file
$ git checkout 915108a7 -- filename

Undo all uncommitted local changes
$ git reset --hard

Undo everything up to this point
$ git reset --hard thispoint
e.g...
$ git reset --hard HEAD
$ git reset --hard 915108a71552

Undo a specific commit (only that one commit), use revert
$ git revert 915108a71552

Undo a bunch of commits all at once...
$ git revert 915108a71..b05f9b935e29fd
Note: This (above) makes you log a message for each commit that is undone here, and each individual reversion is its own commit.

Deleting a local branch (where example is the name of an example branch)
$ git branch example
$ git checkout example
$ git push origin example
$ git checkout master
$ git branch -D example # now local branch is deleted
$ git push origin :example # this deletes the branch from remote

Undo a bunch of commits all at once with a single commit...
$ git revert -n 915108a71..b05f9b935e29fd
$ git commit -m "this is the only message i need because it all gets done in one commit."

Great cheatsheet for me, just dabbling in Git. Thanks!

Post new comment

Don't bother putting in spam links. They'll be set to rel=nofollow and will be removed and reported as spam shortly after submitting.

The content of this field is kept private and will not be shown publicly.
CAPTCHA
Are you human?