Reputation: 1381
On our project we have 2 git branches, 'develop' and 'featureBranch'. Since featureBranch was forked off of develop, develop has been updated with a number of commits. Now I want to merge featureBranch back into develop. To test for any bugs, I did a rebase on featureBranch to pull in the latest code from develop, and have determined everything is good to go with no bugs. Now, what I think I want to do is checkout develop and merge featureBranch back into develop.
As of now, featureBranch is checked out.
The problem I'm having is that when I try to checkout develop, I get an error saying that I have uncommitted changes in featureBranch that would be lost. If I try to commit featureBranch, I get an error saying that nothing has changed and there is nothing to commit. I tried doing a hard reset on featureBranch, but this did not alter or alleviate my situation in any way. If I make a dummy change to a file, like putting in a comment, the commit still tells me there are no changes to commit.
I seem to be stuck and I'm totally lost on how to get out of this mess.
Essentially, I want the current state of featureBranch to be the new state of the develop branch. I want to end the life of featureBranch and get everything back into the develop branch.
NOTE: I'm using the eGit plugin for Eclipse and I would prefer to learn to use this tool for all of my git needs.
Upvotes: 4
Views: 566
Reputation: 3559
Git does not impose a specific workflow on you, but you have got the first step right and figured out a branching strategy. I'm not very familiar with the exact operation of the plugin you are using but I assume the git commands will be more or less directly mapped to a gui button. To use the command line interface in windows: open an explorer window at your source code location and choose open "git bash here" from the context menu.
First update your feature branch (rebase)
git checkout featurebranch
git merge develop
git commit
Now the featurebranch contains all the changes made to the branch develop. Run all your sanity checks and tests and then merge back to develop:
git stash # Keep the uncommited changes in case you need them later.
git checkout develop
git merge featurebranch #will be a fast forward merge as everything have been merged in the step above
git commit
If you run into problems with checkout it could be files added in your workspace exist in the branch you are checking out too.
When commiting with egit in eclipse you must first stage your changes open the "git prespecive" and find your changed files double click on them to move the changes to staged changes and commit.
Upvotes: 1
Reputation: 4446
Such inconsistent behavior constitutes a bug and indeed one matching your description was fixed in the latest EGit release.
Upvotes: 3