Questions tagged [git-fetch]

git-fetch - Download objects and refs from another repository

The git command fetch retrieves changes done in a remote repository.

It will not merge the changes automatically into your local branches, use git pull for this or merge from the origin-branch after doing fetch.

See the man page for full details.

356 questions
12539
votes
38 answers

What is the difference between 'git pull' and 'git fetch'?

What are the differences between git pull and git fetch?
pupeno
  • 256,034
  • 114
  • 324
  • 541
8002
votes
50 answers

How do I force "git pull" to overwrite local files?

How do I force an overwrite of local files on a git pull? The scenario is the following: A team member is modifying the templates for a website we are working on They are adding some images to the images directory (but forgets to add them under…
Jakub Troszok
  • 84,701
  • 10
  • 36
  • 49
2550
votes
31 answers

Git fetch remote branch

My colleague and I are working on the same repository. We've branched it into two branches, each technically for different projects, but they have similarities, so we'll sometimes want to commit back to the *master from the branch. However, I have…
David
  • 28,483
  • 10
  • 38
  • 68
501
votes
6 answers

fetch from origin with deleted remote branches?

When I do git fetch origin and origin has a deleted branch, it doesn't seem to update it in my repository. When I do git branch -r it still shows origin/DELETED_BRANCH. How can I fix this?
Chris Muench
  • 15,874
  • 66
  • 193
  • 332
481
votes
17 answers

The following untracked working tree files would be overwritten by merge, but I don't care

On my branch I had some files in .gitignore On a different branch those files are not. I want to merge the different branch into mine, and I don't care if those files are no longer ignored or not. Unfortunately I get this: The following untracked…
CQM
  • 36,672
  • 69
  • 214
  • 357
306
votes
2 answers

What is the difference between git pull and git fetch + git rebase?

Another question says that git pull is like a git fetch + git merge. But what is the difference between git pull and git fetch + git rebase?
michael
  • 93,094
  • 111
  • 230
  • 334
281
votes
6 answers

Does "git fetch --tags" include "git fetch"?

A nice and simple question - is the function of "git fetch" a strict sub-set of git fetch --tags? I.e. if I run git fetch --tags, is there ever a reason to immediately run git fetch straight afterward? What about git pull and git pull --tags? Same…
davidA
  • 10,282
  • 8
  • 54
  • 76
248
votes
6 answers

What does FETCH_HEAD in Git mean?

git pull --help says: In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD. What is this FETCH_HEAD and what is actually merged during git pull?
Misha Moroshko
  • 148,413
  • 200
  • 467
  • 700
244
votes
10 answers

fetch in git doesn't get all branches

I have cloned a repository, after which somebody else has created a new branch, which I'd like to start working on. I read the manual, and it seems dead straight easy. Strangely it's not working, and all the posts I've found suggest I'm doing the…
Edward Newell
  • 12,996
  • 5
  • 31
  • 36
238
votes
11 answers

Why does git say "Pull is not possible because you have unmerged files"?

When I try to pull in my project directory in the terminal, I see the following error: harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull is not possible because you…
Harsukh Makwana
  • 3,420
  • 2
  • 22
  • 29
204
votes
10 answers

Retrieve specific commit from a remote Git repository

Is there any way to retrieve only one specific commit from a remote Git repo without cloning it on my PC? The structure of remote repo is absolutely same as that of mine and hence there won't be any conflicts but I have no idea how to do this and I…
Varun Chitre
  • 2,681
  • 4
  • 17
  • 31
195
votes
5 answers

Is it possible to pull just one file in Git?

I am working on a Git branch that has some broken tests, and I would like to pull (merge changes, not just overwrite) these tests from another branch where they are already fixed. I know I can do git pull origin that_other_branch but this will…
Audrius Meskauskas
  • 18,378
  • 9
  • 63
  • 78
188
votes
2 answers

Differences between git remote update and fetch?

Is git remote update the equivalent of git fetch?
David
  • 2,393
  • 2
  • 17
  • 16
187
votes
10 answers

How to handle git gc fatal: bad object refs/remotes/origin/HEAD error?

I randomly hit this today while trying to run Git garbage collect: $ git gc fatal: bad object refs/remotes/origin/HEAD error: failed to run repack How do I deal with this?
Ryan
  • 2,637
  • 2
  • 17
  • 11
153
votes
2 answers

How do I fetch a branch on someone else's fork on GitHub?

I've forked from a repo on GitHub. I want to get the code from a branch on another user's fork. Must I clone this user's whole repo to a separate local repo or can I do something like git checkout link_to_the_other_users_branch?
Christian
  • 6,242
  • 4
  • 28
  • 52
1
2 3
23 24