[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cluttering the git tree
From: |
Ulf Jasper |
Subject: |
Re: Cluttering the git tree |
Date: |
Thu, 20 Nov 2014 18:42:05 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Bill Wohler <address@hidden> writes:
> Ulf Jasper <address@hidden> writes:
>
>> I just noticed that I cluttered the git tree with my last commit. All
>> my intermediate commits which were supposed to be visible only to me
>> suddenly appeared in the public repository. Sorry!
>
> Another idea is to put your intermediate commits into a new branch and
> then merge them into master with git merge --squash.
That is, what I was looking for. Thank you, Bill!
This is how I (will) work: I am not changing files on the master branch
but on a temporary branch, while keeping the master branch synced with
the public repository, like so:
a - b - c - d master
\
x - y - z temporary
I am doing commits on the temporary branch so that I can easily switch
branches. Once I have finished working on the temporary thing I merge
the *results* of that work into the master branch
git checkout master
git merge --squash temporary
The magic '--squash' guarantees that there will not be any intermediate
commits. After resolving merge conflicts it looks as if I had made the
temporary changes directly on the master branch. After committing the
changed files (with its own commit message) I get
a - b - c - d - e master
\
x - y - z temporary
where 'e' now contains all the changes of 'z'. Now I'm ready to push
'e' to the public repository and delete the temporary branch (with
'-D'). There is just one commit -- nobody will be bothered with any
intermediate commits. Voila!
Ulf
P.S. I have tried this on a local repository and verified that it
works. I am quite confident that it will work on the official
repository as well. But I may be wrong. We'll see. ;)