Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Git: bring in a file from another branch



2011/7/11 Darren Cook <darren@example.com>:

> Sometimes to really understand a tool you have to start using it for
> real work, and that is where I'm at with git.

s/Sometimes/Always/ ;)

>   custom: a branch of master, with my bug fixes and new features that
> are fed back to the main project.

Consider branching for each feature, as it can be quite annoying to
keep a branch in sync with master all the time. Merge conflicts
abound.

Feature (or bugfix) branches also have the benefit of letting you do
many small commits with good log messages, then squashing the feature
back to master in one commit that describes the whole feature:

git checkout master
git merge --squash my-feature  # where my-feature is the name of your
feature branch

You then keep the feature branch around for the nice granular commit
messages, should you need them in the future.

>   git checkout custom
>   git merge myapp
>
> That brings in all my application code. I'd then read I just specify the
> particular commit I want. So this time I'd been careful to use two
> different commits in myapp, one for library code, one for my application
> files.
>
>  $ git merge 160ef92
>  Updating e7a7f3f..160ef92
>  Fast-forward
>   darren_thoughts.txt                |  124 +++++++++++
>   ...

You want this:

git cherry-pick 160ef92

> Also, is it possible to veto a directory from being checked out in a
> certain branch?

If so, I guess it needs to be done in the branch spec in your
.git/config. I don't know how to do it, though.

> [1]: By the way, to undo the mess the usually all-powerful:
>   git reset --hard
> is not enough. You have to specify the commit you had before. Luckily
> the above merge message gives it. I.e.
>   git reset --hard e7a7f3f

Right. Almost every git command needs a reference, or silently applies
a default. I guess "reset" defaults to HEAD^.

Cheers,
Josh


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links