Tag Archives: git pull

[Solved] git pull Error: error: Your local changes to the following files would be overwritten by merge

The reason for this error is that you have modified the file locally and remotely at the same time

Solution:

Keep local files

git stash
git pull origin master
git stash pop

Do not keep the local file (restore the local file to the previous version and pull down the remote modification)

git reset --hard
git push origin master

 

Windows: How to Solve Git Pull Error

Error content:

Unable to negotiate with x.x.x.x port 22: no matching host key type found. Their offer: ssh-rsa
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The public key of Windows computer has been added to the server. At first, it can be used normally, but suddenly, the code cannot be updated on windows.

Solution:

C:\users\administrator\.SSH (this is the path on my computer. Your computer path may be different. Find it according to the specific situation)

Add a new file config in this directory. The file content is:

Host x.x.x.x
    HostkeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa

Note that x.x.x.x here represents the IP address of your git server.

Pull the code again and restore it.

Git pull does not specify an error message for the branch

When executing git pull or git push, the following error messages sometimes appear:

$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.linux_c++.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "linux_c++"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

Let’s first look at the current branch status:

$ git branch -av
* linux_c++                584efea add cscope and fix fileencoding problam
  master                   ee9d037 v1.0.1: add install.sh
  remotes/origin/HEAD      -> origin/master
  remotes/origin/linux_c++ 584efea add cscope and fix fileencoding problam
  remotes/origin/master    ee9d037 v1.0.1: add install.sh

Current Linux_C + + branch and remote Linux_C + + has the same name, but in fact, this branch is not origin/Linux_The tracking branch of C + + branch, so when git pull is directly used to request to pull a new branch, GIT does not know which branch to pull

Therefore, there are two solutions to this problem. One is to specify the corresponding remote branch name when git pull or git push, such as:

$ git pull origin linux_c++

Another scheme is to set the current branch to track a remote branch. There are two ways to set an existing branch to track a remote branch:

git branch -u remote-name/branch_name branch_name

Or

git branch --set-upstream-to=remote_name/branch_name branch_name

Of course, when you create a local branch, you can directly trace it to the remote branch:

git checkout -b local_branch remote_name/remote_branch

currently our branches are existing branches, so we can input:

$ git branch -u origin/linux_c++ linux_c++
Branch linux_c++ set up to track remote branch linux_c++ from origin.

It should be noted that git branch – U and git branch  — The two options of set upstream to are available only in the higher git version. At least bloggers find that they are not available in 1.7.1, but they are available in 1.8.3.1

[Solved] Git pull error: You have not concluded your merge (MERGE_HEAD exists)

Error encountered while git pull:

localhost:~ lipengfei$ git pull
You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.

This error may be due to the previous pull down the code did not automatically merge git merge — abort fails, use the following method to solve the problem: save a copy of the local modification, pull the latest code from the online, cover the local code, and then recover the local modification

git fetch --all
git reset --hard origin/master
git pull

Git Pull Error: Please specify which branch you want to merge with.

$git pull

$ git pull
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
From github.com:nonfuxinyang/android-study
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> master

Seeing the second tip, we now know a solution. That is to specify the link relationship between the current working directory, working branch, and remote warehouse and branch& lt; br>

For example, we set the master branch corresponding to the remote warehouse

git branch –set-upstream master origin/master

So every time we want to push or pull, we just need to input git push or git pull

Before that, we have to specify the remote branch that we want to push or pull

git push origin master

git pull origin master.

 

git pull There is no tracking information for the current branch.

C:\gitrepo\github.com\NVardell\Other>git pull
remote: Enumerating objects: 613, done.
remote: Counting objects: 100% (613/613), done.
remote: Compressing objects: 100% (485/485), done.
Receiving objects: 100% (35690/35690), 236.66 MiB | 341.00 KiB/s, done.77 eceiving objects: 100% (35690/35690), 236.61 MiB | 410.00 KiB/s

Resolving deltas: 100% (6853/6853), done.
From https://github.com/NVardell/Other
* [new branch] dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/bower-1.8.8 -> origin/dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/bower-1.8.8
* [new branch] dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/eslint-4.18.2 -> origin/dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/eslint-4.18.2
* [new branch] dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/lodash-4.17.19 -> origin/dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/lodash-4.17.19
* [new branch] dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/mongoose-5.7.5 -> origin/dependabot/npm_and_yarn/Clash-Royale/clash-royale-api/mongoose-5.7.5
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch –set-upstream-to=origin/<branch> master

C:\gitrepo\github.com\NVardell\Other>git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch –set-upstream-to=origin/<branch> master

C:\gitrepo\github.com\NVardell\Other> git branch –set-upstream-to=origin/master master
fatal: branch ‘master’ does not exist

C:\gitrepo\github.com\NVardell\Other> git branch –set-upstream-to=origin/master master

C:\gitrepo\github.com\NVardell\Other>git branch –set-upstream-to=origin/master master
fatal: branch ‘master’ does not exist

C:\gitrepo\github.com\NVardell\Other>

C:\gitrepo\github.com\NVardell\Other>git checkout -b master
Switched to a new branch ‘master’

C:\gitrepo\github.com\NVardell\Other>git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch –set-upstream-to=origin/<branch> master

C:\gitrepo\github.com\NVardell\Other>git branch –set-upstream-to=origin/master master
fatal: branch ‘master’ does not exist

C:\gitrepo\github.com\NVardell\Other>git pull origin master
From https://github.com/NVardell/Other
* branch master -> FETCH_HEAD
Updating files: 100% (23153/23153), done.

C:\gitrepo\github.com\NVardell\Other>git branch –set-upstream-to=origin/master master
Branch ‘master’ set up to track remote branch ‘master’ from ‘origin’.

C:\gitrepo\github.com\NVardell\Other>git pull
Already up to date.

C:\gitrepo\github.com\NVardell\Other>