Suppose I clone a git repository from the path /path/to/repo
. The original repository will be a remote called "origin". I can fetch objects from the origin with the command git fetch origin
. This will retrieve all the objects from the remote "origin", including any branches made.
What's curious is that if I explicitly fetch from that same repository with the command git fetch /path/to/repo
, I appear to retrieve all of the commit objects but not any of the branches.
Why is that? Am I not doing exactly the same thing in both cases? How can Git's behavior be so different?
$ git fetch origin. git fetch really only downloads new data from a remote repository - but it doesn't integrate any of this new data into your working files. Fetch is great for getting a fresh view on all the things that happened in a remote repository.
The simplest way to use the git fetch command is to fetch a remote repository: Note: The git fetch command without the remote name retrieves data from an origin. If the remote has a different name, state the name in the command. The output shows the command fetched all the contents from the remote repository, including branches and tags.
After opening the Fuzzy Finder, you can simply type fetch to begin a Git fetch, or pull to initiate a Git pull. Auto-Fetch Changes with GitKraken GitKraken includes a convenient feature that allows you to automatically fetch changes from a remote repository based on an interval you define.
To list all the fetched tags, run: Use the git checkout command to make the contents locally available to a new branch or use git merge to synchronize local repository information. To fetch a specific branch from a repository, run this command: For example, to fetch a branch named test from the origin, run:
Named remote use their configuration where they setup a refspec
schema when this remote is fetched:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = /path/to/repo
So, these two format are equivalent:
git fetch origin
git fetch /path/to/repo +refs/heads/*:refs/remotes/origin/*
Basically: git fetch <path> <source>:<destination>
. And the destination is important here because it's where the remote HEAD and branches pointer are stored.
By doing git fetch /path/to/repo
, you don't set any refspec. As so, it only fetches the commits, not the objects because git
hasn't been instructed to get and store them.
There may be some details or naming convention incorrect here, feel free to edit. But the global idea should be correct
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With