On 20. Apr, 2010, at 23:37 , Brad King wrote:

> Alexander Neundorf wrote:
>> Hi,
>> 
>> I have two small commits in my local cmake git repository.
>> Both are working, but I'd like to push only of them right now.
>> I haven't found out how to do this.
>> That's what I tried:
>> 
>> ...
>> File .git/COMMIT_EDITMSG saved
>> [master 79963cf] -fix typo in HAS_CXX docs (#10578)
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>> hammer:~/src/CMake/CMake-git/Source$ git push --dry-run 79963cf
>> fatal: '79963cf' does not appear to be a git repository
>> fatal: The remote end hung up unexpectedly
>> hammer:~/src/CMake/CMake-git/Source$ git log
>> 
>> 
>> The git-push man page wasn't very helpful either, the examples given there 
>> just deal with different branches, but not commits.
>> 
>> Is it possible to push just specific commits ?
> 
> Create a local branch on which to work, starting at origin/master:
> 
> $ git fetch origin
> $ git checkout -b temp origin/master
> 
> Cherry-pick the changes:
> 
> $ git cherry-pick <sha1-of-one-commit>
> $ git cherry-pick <sha1-of-other-commit>
> 
> Push the new history:
> 
> $ git push origin 'temp:master'
> 
> Rebase your other work on it
> 
> $ git rebase temp master
> 
> This should automatically exclude the commits.
> Then delete the temporary branch:
> 
> $ git branch -d temp
> 
> -Brad
> 
For my local Git work I now always use StGit for such things. Essentially it is 
a patch-management tool, allowing you to operate on a stack of patches. You can 
push, pop, reshuffle and squash patches to your heart's content, all managed 
inside Git, where all changes are also recorded in a special Git branch such 
that you can always undo/redo. It is infinitely cool ;-) Of course, it is a bit 
rough around the edges and doesn't like it if you use plain Git commands that 
modify/create/delete commits while there are patches applied. Also, some of the 
StGit commands have the same name as Git commands, but with different meaning 
which can be quite confusing at times. But all in all, it greatly simplifies 
working with a local development branch.

What I usually do, is to start my StGit stack based on top of fresh checkout, 
where master is at the same commit as origin/master (or whatever branch/remote 
combination you choose). From there I create new patches (i.e. commits) which I 
can apply/unapply and reorder as needed. Now, if upstream makes some commits, I 
do a "git fetch origin" and the a "stgit rebase origin/master" to rebase my 
local patch series on top of the remote patches. Once I think my patches are 
fine, I apply the ones I want to publish using "stgit push" and then do a 
"stgit commit", pushing them out of the stack into the Git history which I then 
push to the remote or merge into some other branch.


Michael

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to