简体   繁体   中英

Git: Specify the remote and local branches

I want to use git commands with both, remote and local branch names. For example, instead of specify the origin with set-url origin, I want to use it on the command.

So, to use pull, it should looks like:

$ git pull origin dev

I see it in some places, but, I don't understand very well, I'm putting origin content on dev?

Maybe it's more accurate use:

$ git pull origin/dev dev

But, I can use it only if I'm in dev?

To see it more clear:

$git branch
*master
dev
$git pull origin/dev dev 

This last would work as I expected, updating my dev branch with remote dev?

But, I can use it only if I'm in dev?

Yes.

You can only update a local branch that is currently checked out. So git pull will always fetch from the given remote and branch (or the tracking branch , if configured) and try to merge into the currently checked out branch .

In other words, in your case you have to git checkout dev and then git pull origin dev (to merge the remote branch dev from origin into your local branch dev ).

The arguments after git pull refer to the remote and its branch that you want to merge in, never to a local branch.

See also the git pull documentation .

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