Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » How to replace local branch with remote branch
How to replace local branch with remote branch [message #1763714] Thu, 18 May 2017 21:57 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 510
Registered: July 2009
Senior Member
This is more of a pure git question, but perhaps there's a shortcut for this in egit.

We use BitBucket Server as our remote.

I created a branch from master in my remote, did some work, committed changes, commited more changes, then pushed my branch to remote. I then made more local changes, committed them and pushed them.

At some point, I think I had started to commit/push some changes in the git staging view and realized I had to make another change, but I decided to try "Amend Previous Commit" instead. I did that, but it reported an error that it didn't elaborate on, and at that point I got stuck in some sort of conflict situation.

Now, when I run "git status" from the shell, I get this:
On branch blah
Your branch and 'origin/blah' have diverged,
and have 1 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
Changes not staged for commit:


I tried doing a pull, and that produced conflicts. I tried doing a hard reset, but that just puts me back in the state reported by "git status".

At this point, I'd be perfectly happy to blow away my local branch and replace it with the remote branch (or vice versa), and then continue making additional changes. I don't understand how to do that.
Re: How to replace local branch with remote branch [message #1763733 is a reply to message #1763714] Fri, 19 May 2017 07:39 Go to previous message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 233
Registered: July 2009
Senior Member
After checking out the local branch go to History view, right-click on the commit where the remote branch points to and execute "Reset->Hard". Then your local branch points to the same commit as the remote branch.
Previous Topic:EGit : Windows + LFS + ssh
Next Topic:Modify commit message from Eclipse plugin
Goto Forum:
  


Current Time: Sat May 27 17:38:40 GMT 2017

Powered by FUDForum. Page generated in 0.01655 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software