I had edited a file and pushed it to the repository. Another developer did not pull the repository files to his tree and edited the file and pushed it to the repository, over-writing my changes. How do I merge both versions or access both so I can merge them manually?
First thing, you should never allow two or more developers to push to same branch ever. Let them start work with their own branch and commit on the same. Later the branches can be merged by any of the responsible developer.
Second, If you two were on same branch then the other developer should not be able to push, because the remote (Bitbucket etc) host would disallow any such reference mismatch.
Suppose you started work at commit A. He too started at A. Then you committed and pushed creating commit B. Now when he tries to push on the same branch he wont be able to do so, because A --> B reference already exists, A --> C can only be created if it is on a different branch.
Therefore he must pull B and then commit and push and hence creating the flow A --> B --> C.
Here it is possible that he actually pulled your commit, but overlooked your changes and committed his own code and therefore your changes lost.
Now answer to your real question:
To do the merge manually just archive (right click on the commit and select Archive) the sources from sourcetree for both commits viz. yours and his. Use some diff / compare tool to compare them and merge. Personally I prefer Beyond Compare by Scooter Software, but you can choose whatever you feel comfortable.
When you have your final merged version, simply commit it to the repository.
Note that once you push your changes, it sits in the repository permanently. You can never ever accidentally overwrite those files. This feature always comes handy if you ever get something messed in your files.
Let me know if I could address your issue. If not I'd be glad to assist if you precisely provide me the scenario with you.
It's possible that the second developer actually did overwrite the commit if he did a "force push" (push -f) You should almost never do a force push and many people configure their repos to disallow them (I know you can do this on Stash, I don't know about BitBucket but I would guess you could).
If your commit is still there, you should be able to do this
1) Checkout your commit
2) Create (and checkout) a branch at that commit
3) Make an inconsequential change to the code (maybe add a blank line somewhere)
4) Stage and commit the change
3) Checkout the original branch ("master" or whatever branch you were both committing to in the first place)
4) Merge the branch you created into the current branch
5) If necessary, resolve any conflicts
6) If you had to resolve conflicts, stage and commit the changes.
At command line, it would look like this:
git checkout <commitID>
git checkout -b <newBranchName>
<edit file to make an inconsequential change>
git commit -a -m "creating a branch to merge from"
git checkout master
git merge <newBranchName>
<edit file to resolve conflicts>
git commit -a
You can of course follow the same steps in SourceTree.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG