Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: Your branch and 'origin/somebranch' have diverged - how to throw away local commits

Tags:

I have a question that most closely matches my problem was made, but could not add a comment.

git: Your branch and 'origin/master' have diverged - how to throw away local commits?

I ran the tips and answers to the question above, but nothing decided. I am following with a progress chart using the sofwae source tree. I close the software and run the commands in the bash git. But there is the same mistake quoted.

# Your branch and 'origin/master' have diverged, # and have 7 and 11 different commits each, respectively. #   (use "git pull" to merge the remote branch into yours) 

I am also facing the same problem. follow the steps running 2 comentos but not worked. I think my problem is that before I made a checkout for a indiividual head, made a commit in individual head and then I went back to the tree branch / master, and commit that I did, I believe that references the tree head individual. In summary I can not undo this commit, I'm displayed graphically on SourceTree software

EDIT - ADD INFORMATION: I'd like to throw out of the unpublished commits and make server checkout. But the solutions I found an internet not working. I also tried git reverse in gitBash the console displays the message that I do deveo

$ Git status On branch processos_criminais_151029 Your branch and 'origin / processos_criminais_151029' have diverged, and 7 and 11 have different commits each, respectivamente.    (use "git pull" to merge the remote branch into yours)  Changes not staged for commit:    (use "git add <file> ..." to update what will be committed)    (use "git checkout - <file> ..." to discard changes in working directory) 

I tried the two solutions but none worked. If I try and push gives the conflict a huge amount of files, and I tried to solve these problems with the automatic merge, but to make a new git status he points out that the same quantidde files are conflicts.

like image 605
Paulo Victor Avatar asked Sep 17 '15 12:09

Paulo Victor


People also ask

How do you resolve your branch and origin master diverged?

This can be properly resolved by committing changes from the merge first by git commit , then adding and committing the unstaged changes as usual (e.g. by git commit -a ). Show activity on this post. Replace 123 with number of commits your branch has diverged from origin.

Why is git branch diverged?

A branch in git is a series of interrelated commits. If two branches follow a non-linear path then they diverge each other. The diagram shows two diverged branches master and feature. Step 1 − Create an empty repository with an initial commit.

What does diverged mean in git?

A Git branch divergence consists of the difference between the current state of two branches and the list of changes (commits) performed in each branch from the common state to get the current divergence (commits ahead and behind).

How do I drop a commit?

You can simply remove that commit using option "d" or Removing a line that has your commit. In the latest git version there is no more option d.


1 Answers

Your branch and 'origin / processos_criminais_151029' have diverged

So of course, resetting to origin/master will not work. You will have to reset to that remote branch in order to reset your local branch to it.

So the commands you need to run are this:

git fetch origin git reset --hard origin/processos_criminais_151029 
like image 134
poke Avatar answered Sep 19 '22 03:09

poke