Question

I am working on a project with a friend using a remote git tool bitbucket.org. So far that we have been working on the master branch at different times, and then commit and push those changes to the remote site for the other to use.

Now he has committed and pushed his changes out to the repository while I was working on my own, and I am afraid that if I push out my commit it will re-write his commit completely. Are my fears correct? I think I should create a new branch, fetch his changes into the master branch, and then merge the two, and then push. Is this a good strategy? Or I am worrying for nothing. A little advice would be great.

Was it helpful?

Solution

The whole idea of VCS is that you won't corrupt data by doing this. You can attempt to push, if your code is out of sync you will be told you have to accept the upstream changes before you can commit.

Once you have accepted the changes and merged them you can apply your code to the HEAD.

OTHER TIPS

In general this shouldn't happen, but you have to pay attention. For example, if there are conflicts between your friend's code and your code, you'd want to pay attention to how you resolve the conflict. (I.e. don't blindly accept either your friend's or your own version in toto--you may have to hand-resolve the conflict.)

You might practice intentionally changing the same file just to get the hang of things.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top