Frage

I've been using 'git pull origin' to check out updates to my friend's project, but I wonder if I should be using 'git pull remote' instead.

War es hilfreich?

Lösung

When you use the command:

git pull origin

"origin" is the name of your remote repository that you're specifying in that pull statement.

Take a look at your .git/config file. You'll see something like this:

[remote "origin"]
  fetch = ...
  url = ...

If you have multiple remotes, then you'd be able to specify which one to pull from. For example, you might have a remote "origin" repository on a backup hard drive that you push to, and when you're ready to release to github, you like to squash first, then push there. You'd have two remotes listed in your .git/config file - one for your backup drive, and one for github.

Andere Tipps

The first argument to git pull is the name of the remote repository. Typically a repository cloned from another has exactly one remote, which is named “origin”. You would only type git pull remote if you had a remote named “remote”; the place you saw that probably intended it to stand in for the actual name of a remote in your repository.

You can find out the remotes you have registered using the command git remote, or git remote -v which will also give the address(es) of the remote repository.

Remotes can be named whatever you like, and it makes no difference to Git; “origin” is just a default name.

origin is the name of the remote you are pulling from.

Unless your remote is called remote, doing git pull remote doesn't make sense.

You might have been confused by syntax and example. git pull <remote> is most likely a syntax in some manual/guide you read. git pull origin is a sample usage of the git pull syntax.

When you say git pull origin, you are updating you local repo with changes from the origin repository, which is typically the repository your local repo was cloned from. This is the default way of updating your local repo.

On the other hand, git pull <remote> is a syntax that indicates you can actually update from any remote repo, and not just your origin repo.

more info: http://git-scm.com/docs/git-pull

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top