Problems encountered by git pull and solutions!

Question 1: Solve the GIT code repository out of sync

When doing a git pull today it appeared:

 

[root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull  
Enter passphrase for key '/root/.ssh/id_rsa':  
Updating 70e8b93..a0f1a6c  
error: Your local changes to the following files would be overwritten by merge:  
        rest/lib/Business/Inventory/ProductStatus.php  
Please, commit your changes or stash them before you can merge.  
Aborting

 Solution:

 

Execute git checkout -f, then execute git pull to recheckout

 

[root@gitserver /data/work/www/rest/lib/Business/Inventory]# git checkout -f  
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.

 When you execute git pull again, you can:

[root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull  
Enter passphrase for key '/root/.ssh/id_rsa':  
Updating 70e8b93..a0f1a6c  
Fast-forward
 rest/lib/Business/Inventory/ProductStatus.php |    1 +  
 1 files changed, 1 insertions(+), 0 deletions(-)  
 mode change 100644 => 100755 rest/lib/Business/Inventory/ProductStatus.php

 

The second question: the default address of git pull.

1. When git is under the branch of master, the default remote is origin;
2. When using git pull that specifies remote and merge under the branch of master, use the default remote and merge.
 
But for the project you built yourself and push it to the remote server, there is no such content, you need to configure it yourself.
If you run git pull directly, you will get this result:

#Prompt after executing git pull:

$ git pull  
Password:  
You asked me to pull without telling me which branch you  
want to merge with, and 'branch.master.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 "master"]  
 remote = <nickname>  
 merge = <remote-ref>  
   
[remote "<nickname>"]  
 url = <url>  
 fetch = <refspec>  
   
See git-config(1) for details.

 #Solution, configure as follows through git config.

git remote add -f origin [email protected]:rest.git  
git config branch.master.remote origin  
git config branch.master.merge refs/heads/master

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326569636&siteId=291194637