0

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.

random
  • 9,774
  • 10
  • 66
  • 83
ThangNguyen
  • 197
  • 1
  • 12
  • 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 Answers1

2

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 of origin/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 of master, keeping master for being an (untouched) mirror image of origin/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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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
  • @NoufalIbrahim: sorry, what's OP means? – ThangNguyen Jan 23 '14 at 15:56