git-checkout: Advanced use

Hello all,

Yes, this post doesn't have a nice name... but let's go anyway:

1st tip: Using git-checkout to produce clean patches.

Assumptions: using that same 'exp' branch

Story: Let's say we're implementing a new driver in our 'exp' branch and we're committing even unbuildable code, of course, git lets us do it. But you won't send the whole change history to any public list. Once you finish the driver you send only one patch with the finished driver. So, how to do it??

We can change to a new branch, let's say 'new-drivers', and commit the finished file there.

$ git-checkout master
$ git-checkout -b new-drivers
$ git-checkout exp path/to/our/driver.c
$ git-commit -s

2nd tip: Tracking remote branches

Assumptions: you're working on a public tree with at least two branches (master and fix - for example)

Story: Let's say you're working on project.git and that tree has two branches: master (of course) and fix. You wanna track what's happening on branch fix. So you'd run:

$ git-clone http://project.org/project.git
$ cd project$ git-checkout --track -b fix
$ git-pull

From now on, when you run:

$ git-pull

It'll fetch differences for both branches.

3rd tip: Switching a file n-commits back

Assumptions: none

Story: Let's say you wanna switch-back a file N-commits earlier. You'd issue:

$ git-checkout branch
$ git-checkout branch~n path/to/file.c
$ git-diff path/to/file.c

That's all for now...

See y'all

VN:F [1.9.0_1079]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.0_1079]
Rating: 0 (from 0 votes)

Leave a Reply