Git pull always merges

I have a problem where whenever I run git, pull it onto my production server, this will lead to a merge.

If I run the git status, I get the following output:

$ git status # On branch master # Your branch is ahead of 'origin/master' by 351 commits. # (use "git push" to publish your local commits) # nothing to commit, working directory clean 

Good, so there is 351 local commit. But git diff does not detect local changes:

 $ git diff origin/master..HEAD (no output) 

If I use git log origin / master..HEAD, I only see messages like "Join branch" from ****.

Any ideas on how I can get rid of these 351 local commits that seem useless?

+5
source share
4 answers

First of all, just in case, back up your current branch:

 git branch master-bak 

If git diff origin/master..HEAD gives empty output, it means that your current branch has identical content as origin/master . In this case, you can simply reset to use your local branch in the same state as origin/master :

 git reset origin/master 
+3
source

I think that after the last time you delete the remote master, the source / host had some return, therefore. If you want to be modern with the remote wizard, simply delete the local wizard and create a new one.

 git checkout another branch git branch -D master git checkout -b master git pull origin/master 
0
source

Obviously, you are not working alone, so someone made a push (your local repo has a different history from the remote one), after which everyone else should do git reset --hard origin/master to save the same story with the source / master .

0
source

When git status indicates that your branch is ahead of "origin / master" at 351 commit, it actually means origin / master. it just means that your repo has a pointer named origin / master pointing to a commit, which is the HEAD of this remote branch, and your master is ahead of this commit.so, when you run git pull, your local changes will also be merged, and in this case, you need to check the new branch or commit again after the merge.

0
source

Source: https://habr.com/ru/post/1239133/


All Articles