[icinga-devel] Small Git Howto published

Bernd A. bernd_a at gmx.de
Sun Jun 7 13:02:56 CEST 2009


mareadmin schrieb:
>> as promissed:
>> https://dev.icinga.org/wiki/icinga-development/GitHowTo
>>     
> well, now that i worked with the master , created a branch
> worked with it an commited a patch .. what now?
> how do i work with the
> - master
> - my branch
> - updates from the online-source?
>
> do i delete my_branch after its been implemented/rejected
> in the main tree?
> how to merge with the official master (orr do i always have to
> git-clone from the official online_tree?
>
>
> maybe, thats some points for your wiki, because thats where
> i am stuck right now. 
>   

You can always delete your branch at any time:
git checkout master
git branch -D my_branch

The upper case D deletes the branch regardless if it
has been merged into master or not. So be careful!

The lower case d is safer. The branch is only deleted if
it is merged into master (git branch -d my_branch).

For example: I've created two branches, docbook-updates
and docbook-updates_nagiosplugins-make. I've sent the
patches to the mailing list on June 2nd 2009. After Hendrik
applied both patches to the master, I've pulled the
updates from the git repo (git checkout master; git pull).

But I still can't safe-delete my two branches:

bernd at l03:~/Git-Repos/icinga-core$ git branch -d docbook-updates
error: The branch 'docbook-updates' is not an ancestor of your current HEAD.
If you are sure you want to delete it, run 'git branch -D docbook-updates'.
bernd at l03:~/Git-Repos/icinga-core$ git branch -d 
docbook-updates_nagiosplugins-make
error: The branch 'docbook-updates_nagiosplugins-make' is not an 
ancestor of your current HEAD.
If you are sure you want to delete it, run 'git branch -D 
docbook-updates_nagiosplugins-make'.

Maybe there's more than one possibility to achieve this.
Here's what I did, using Git's rebase command:

bernd at l03:~/Git-Repos/icinga-core$ git checkout docbook-updates
Switched to branch "docbook-updates"
bernd at l03:~/Git-Repos/icinga-core$ git rebase master
First, rewinding head to replay your work on top of it...
Nothing to do.
bernd at l03:~/Git-Repos/icinga-core$ git checkout master
Switched to branch "master"
bernd at l03:~/Git-Repos/icinga-core$ git branch -d docbook-updates
Deleted branch docbook-updates.

bernd at l03:~/Git-Repos/icinga-core$ git checkout 
docbook-updates_nagiosplugins-make
Switched to branch "docbook-updates_nagiosplugins-make"
bernd at l03:~/Git-Repos/icinga-core$ git rebase master
First, rewinding head to replay your work on top of it...
Nothing to do.
bernd at l03:~/Git-Repos/icinga-core$ git checkout master
Switched to branch "master"
bernd at l03:~/Git-Repos/icinga-core$ git branch -d 
docbook-updates_nagiosplugins-make
Deleted branch docbook-updates_nagiosplugins-make.

Please note the "Nothing to do" line when Git tries to
apply my own changes. Since the changes have already
been applied to master of the remote repository,
there's no difference between the
master branch and my own branch now.

Git deletes the branches with the lower case d in
git branch -d my_branch_name

Hope this helps a bit...

Regards
Bernd





More information about the icinga-devel mailing list