user3274539
user3274539

Reputation: 697

Git tracking remote branch

I have one problem, I have been reading about that but I am not sure which solution is correct and as of now I am unable to test which solution is the right one. So, I am working on a remote branch, changing things, other people are working here too. When I am done I want to push but other people already changed that branch and I can't do that. Whenever I do pull it want to merge the branch. Is there any other way to get latest commits from branch without merging and then push my changes?

Upvotes: 0

Views: 60

Answers (1)

VonC
VonC

Reputation: 1328752

If you want to see the most up-to-date upstream branch, you can fetch it (no merge here) and create a temporary branch:

git fetch
git checkout -b  tmp origin/master

That way, you can switch back and forth between tmp and master (your own local branch), and compare their differences (in term of file list).

Note that you won't be able to push your changes without forcing a push and erasing the upstream history.

The best course of action would be to rebase your master branch on top of origin/master:

git pull --rebase

(A merge would occur there, but more importantly, your own commits would be replayed on top of the most up-to-date version of the upstream master branch)

Then you would be able to push your own changes.

Upvotes: 2

Related Questions