Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » sync two remote branches(sync branches)
sync two remote branches [message #1231535] Tue, 14 January 2014 17:42 Go to next message
Zareh Vazquez is currently offline Zareh Vazquez
Messages: 1
Registered: January 2014
Junior Member
Hi,

I need your help that might sound very simple, I have two branches, by mistake one change was pushed to the wrong branch and now those two branches are out of sync.

By example, branch A is mine main development branch where I push the changes, when all the changes are ready we merge it everything with branch B, but by mistake a change was pushed directly to branch B and now branch A and B are out of sync.

What can use using the plugin in Eclipse to sync those two remote branches, basically I could copy everything from one to the other.

At this point I could just copy everything from branch A into branch B to keep them back on sync.

Thanks in andvance for your help,

Zareh
Re: sync two remote branches [message #1232228 is a reply to message #1231535] Thu, 16 January 2014 08:29 Go to previous messageGo to next message
R Shapiro is currently offline R Shapiro
Messages: 386
Registered: June 2011
Senior Member
Keep in mind that a branch in Git is nothing more than a pointer to a particular commit in the repository. You can move the pointer around with the 'reset' operation. So If you want branch B to point at the same commit as branch A, just reset B to A. Do that in EGit by checking out B, then running the 'Reset' command and selecting A as the commit to reset to.

You'll also see three options in the EGIt reset dialog: hard, mixed and soft. These let you choose what happens to the index and working files after the branch pointer is reset. The hard option updates both to match the new branch head. This is probably what you want in this case. You'll be asked to confirm, since working files will be modified by this operation.

The mixed option updates the index but not the working files. The soft option updates neither the index nor the working files. These two are very handy if you want to reorganize the commit structure of the last N commits on some branch without changing the working files.

In general reset is a powerful operation and you should get comfortable with using it to get the most out of Git.




Re: sync two remote branches [message #1232660 is a reply to message #1232228] Fri, 17 January 2014 07:50 Go to previous message
R Shapiro is currently offline R Shapiro
Messages: 386
Registered: June 2011
Senior Member
Oops, I read your question too quickly and provided an irrelevant response having to do with local branches.
Sorry.

For the case you describe I would probably delete remote branch B, then recreate it to match A.

EGit supports remote branch deletion via the dialog in Team -> Remote -> Push ...
Previous Topic:EGit not playing nice with command-line Git?
Next Topic:Problems changing the committer ID
Goto Forum:
  


Current Time: Thu Aug 21 10:19:12 EDT 2014

Powered by FUDForum. Page generated in 0.14286 seconds