Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

git making two commits when branch is behind

Hi,
I have made a local commit to the repo.
The remote branch is ahead by one commit. So I forgot to take the pull and commit my changes to local.
I did a git pull and git push
I saw the following 2 commits in the branch. The last one is weird.
whats the need for that to be created. how can i avoid that ?
So here my local branch was on 1f6a commit
and the origin was at 0ca commit

when i tried to push i got the error message :
On branch stage
Your branch and 'origin/stage' have diverged,
and have 1 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

after performing git pull i did git commit
and the top two commits were produced. Ideally only one commit should have
produced that of Remove nanosecond message.
How to avoid this top commit.
User generated imageOne way is to uncommit your latest change and then take a git pull
How to uncommit the lates change that is in local ?

This problem is mainly coming when i am committing something and the origin branch is
ahead of local branch.
The Merge branch 'stage' of 10.1.5.12:app-portal into stage commit
which was automatically created has this in it. It shows two parents !!
User generated image
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial