I'm using Git to manage my project but I had a problem with role of branches. Any branch in Git can push code of them to remote/master branch, so it make me confuse when I merge to stable versions. Because may be a developer pushed to my master branch.
-
possible duplicate of [Git for beginners: The definitive practical guide](http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide) – First Zero Jan 23 '14 at 04:33
-
If it helps here is another website that I use - http://nvie.com/posts/a-successful-git-branching-model and if you prefer to see the merges visually - something like BitBucket, GitHub or Stash has `pull` requests so that you can see the merges and approve them. – First Zero Jan 23 '14 at 05:13
1 Answers
In addition of basic branch management, you can:
make sure the remote doesn't accept non-fast-forward merge: so at least if a developer directly pushes new commits to
origin/master
, it would be commits easily merged to the new branch (that forces a developer to first rebase his/her work on top oforigin/master
before attempting a push).
See "What's a “fast-forward” in Git?" and "Why does git use fast-forward merging by default?".you can more easily separate dev branches by creating them in their own namespace:
username/master
instead ofmaster
, keepingmaster
for being an (untouched) mirror image oforigin/master
.you can add a description to a branch, leaving one more clue as to what that branch is for: see "Branch descriptions in git":
git branch --edit-description
. That information will be pushed along to a remote repo, for others to see.finally, you can choose and follow a git workflow (like git-flow) in order to manage the convention around branch usage.
-
Good advice but I don't think the OP is knowledgeable enough to apply it. There's a lot of technicality like "fast-forward" etc. which will confuse rather than help. – Noufal Ibrahim Jan 23 '14 at 07:15
-
@NoufalIbrahim you do realize that this answer is intended to be helpful to *more* than *just* the OP, right? Plus, those "technicalities" might prompt the OP to discover a bit more about Git, which is always good. – VonC Jan 23 '14 at 07:45
-
I do. My comment however, was mostly directed to the OP to whom your detailed answer might, in my opinion, seem overwhelming. – Noufal Ibrahim Jan 23 '14 at 07:56
-
@NoufalIbrahim Then I agree with you; Hopefully, it will open new horizons for the OP or others in their Git discovery journey. – VonC Jan 23 '14 at 07:59
-