简体   繁体   中英

Why git pull origin branchA:branchA can't work and pull origin branchA can work?

my git action is below:

git pull origin mybranch1.3.3:mybranch1.3.3 ------> it rejected and tell me mo-fast-forwrd

git pull origin mybranch1.3.3 --------> works well.

and what's the difference? isn't the last "mybranch1.3.3" means my local branch ?

springdeiMac:myApp qiushuitian$ git pull origin mybranch1.3.3:mybranch1.3.3
remote: Counting objects: 196, done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 95 (delta 61), reused 0 (delta 0)
Unpacking objects: 100% (95/95), done.
From 192.168.1.39:myApp
 ! [rejected]        mybranch1.3.3   -> mybranch1.3.3  (non-fast-forward)
   a1a652f..3fd1572  mybranch1.3.3   -> origin/mybranch1.3.3
springdeiMac:myApp qiushuitian$ git pull origin mybranch1.3.3
From 192.168.1.39:myApp
 * branch            mybranch1.3.3   -> FETCH_HEAD

this is git pull syntax

git pull [<options>] [<repository> [<refspec…>​]]

where options , repository and refspec are optional parameters, but you must supply them to git command, as it is recommended otherwise the default behavior would be as mentioned by GIT Ducumentation

Often people use git pull without giving any parameter. Traditionally, this has been equivalent to saying git pull origin

in the first command you have used Refspec ,

so in git pull origin mybranch1.3.3:mybranch1.3.3 the LHS of : is your <src> and RHS to : is your <dst> . and to ignore this error you can use + in your Refspec

As Git says

The format of the refspec is an optional + , followed by <src>:<dst> , where <src> is the pattern for references on the remote side and <dst> is where those references will be written locally. The + tells Git to update the reference even if it isn't a fast-forward.

And yes in the second command mybranch1.3.3 is your local branch. This command means to fetch the data from your origin and merge it to your local mybranch1.3.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM