Handy Git commands

Its been a while since I’ve posted but I’ve been getting to know Git a bit better over the past few weeks in an effort to include it as part of our development process.

In the meantime however I’m using it to manage my own files and to merge other developer’s work into my own work. Here are just a few of the commands that I’ve found have helped me so far.

This handy bit lets you compare the differences between two branches with the optional file on the end:
git diff --name-status [branch_one]..[branch_two] [file_path]

This displays a nice command line base graph of the commits you’ve made, each commit taking up just one line with the git message appended to the line:
git log --graph --pretty=oneline --abbrev-commit

After installing kdiff3 and following this handy run through using git difftool is much nicer when going through file diffs with a co-worker (can be done with branches too as above):
git difftool [commit_one] [commit_two]

I may add some more as I get more and more into Git but at the moment they’re the few handy ones I can recall.

Advertisements

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