I have a branch from master in my local machine. I know how to merge
something to master repo. but question is this.
Think some other developer has changed the master repository by pushing changes to it and at the same time I'm going to merge changes to the master repository from by branch.
What will happen at this situation.
What should I do in this type of situation. I tried to do following from my branch.
- added my changes with ->
git add *
- then committed with ->
git commit -m "my commit"
- then push to my branch with ->
git push -u origin my_branch_name
- then changed the repository to master with ->
git checkout master
- then merged branch to master with ->
git merge my_branch_name
up to this stage it was successful. then I tried to push with following command (before few minutes ago, another developer has pushed to master)
git push origin master
then it says followings.
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@bitbucket.org:abcdef/cups.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
at this stage, what should I do.
- should I get a
pull
after the merged step and then push (in this stage if i get a pull, what will happen.) or - do I have to do something like
git stash
, thenpush
and something like that.
hope your help with this. thank your very much.