Reputation: 2018
Here i am writing the git commands i followed to commit the code.
git merge <branch1> --no-commit
So i got the code from that branch and i started working on it. I did merge code into master only. Now after i have completed my code and try to get changes from master as others also working on it.
git pull origin master
I Got error Saying that MERGE_HEAD Exists please commit your files. So i did commit the code by entering these commands.
git add .
git commit -m "<commit message>"
Now i tried to pull the code by rebasing it as i normally do.
git pull origin master --rebase
Now everything is fine and commit also looks good. So i have gone to codebase and checked the files. All my changes are gone. Where did i do wrong?? Still I dont know. Please help me to find whats wrong. Thank you in advance.
Upvotes: 1
Views: 2921
Reputation: 864
Here are the steps to bring your changes from your branch to master :
git checkout master
that is the branch where you want to push your changes
git pull origin master
to retrieve commits of your team
git checkout your-branch
to retrieve your branch
git rebase master
to retrieve all the commits of master and after that put your changes
git checkout -b your-branch.1
you cannot push your commits on your-branch because your remote is not the same that your local branch as rebase rewrites history
git push origin your-branch.1
push your branch that you are ready to merge
git checkout master
that is the branch where you want to merge
git merge --no-commit --squash your-branch.1
to merge your branch with master. Squash will bring all your commits in one. No commit will let you write a nice commit message
git commit -m "here is my commit message"
be kind let your team members what your changes are about
git push
publish your changes
Upvotes: 2
Reputation: 9248
git merge <branch1> --no-commit
So i got the code from that branch and i started working on it.
This is not an answer, but here you seem to doing it wrong. By not committing you are mixing your development changes with previous merge. This can mess further history analysis.
Upvotes: 0