Skip to contentSkip to conversation

Is there a way to lock branches in GIT?

DISCUSSION ask4thunder 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi GIT Gurus,

1. If there are 2 user are working and having their own clone and branches (not master, other branches). and there is another parent clone with a branch (not master). Can these 2 users merge to the parent clone branch at the same time? or only one user will be able to merge first and then the other. in other words, will the target branch be checkedout to that user alone and other user cant checkout that branch or use the checked out branch.

2. Is there a way to lock branches, so that if a user want to merge his changes to a parent branch of another clone, it can be unlocked for him alone? Hope you can help me on this.

Thanks
ask4thunder

Signature · 2 lines
View this message in context: http://www.nabble.com/Is-there-a-way-to-lock-branches-in-GIT--tp23204641p23204641.html
Sent from the git mailing list archive at Nabble.com.
#1 lore raw
Quoted 7 lines · On Thu, 23 Apr 2009, ask4thunder wrote:

1. If there are 2 user are working and having their own clone and branches (not master, other branches). and there is another parent clone with a branch (not master). Can these 2 users merge to the parent clone branch at the same time? or only one user will be able to merge first and then the other. in other words, will the target branch be checkedout to that user alone and other user cant checkout that branch or use the checked out branch.

You can't merge into a remote repository; you can only move the remote repository forward. That is, when you "push" to the remote repository, you replace what it currently there with a commit you supply that's based on the commit that's there.

Two people can't both push to the same remote repository at the same time, because each of them will be sending something that the other hasn't based their commit on. Whoever's second will be refused, and will have to fetch the other commit and make a merge commit, which is based on both the commits. Git makes sure, in updating the remote repository, to do the necessary locking to have one side or the other lose the race cleanly.

Quoted 3 lines

2. Is there a way to lock branches, so that if a user want to merge his changes to a parent branch of another clone, it can be unlocked for him alone? Hope you can help me on this.

Not with git program support. Of course, you can use Unix permissions to get exclusive write access to the branch and prevent another else from updating it. And, of course, you can have a branch that's always your own (Linux kernel development works primarily by every developer having one or many private branches, and it's rare for multiple people to have write access to the same branch). But there turns out not to be much benefit to branches that people can sometimes but not always write to, in a system where everybody has local branches they can always write to regardless of what other people do.

-Daniel
*This .sig left intentionally blank*