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.

378 questions
13368
votes
38 answers

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

What are the differences between git pull and git fetch?
pupeno
  • 271,514
  • 122
  • 354
  • 592
8913
votes
47 answers

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

How do I force an overwrite of local files on a git pull? My local repository contains a file of the same filename as on the server. error: Untracked working tree file 'example.txt' would be overwritten by merge
Jakub Troszok
  • 94,151
  • 10
  • 39
  • 52
2909
votes
32 answers

Git fetch remote branch

The remote contains various branches such as origin/daves_branch: $ git branch -r origin/HEAD -> origin/master origin/daves_branch origin/master How do I checkout daves_branch locally so that it tracks origin/daves_branch? I tried: $ git fetch…
David
  • 32,703
  • 11
  • 44
  • 72
653
votes
19 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
  • 40,822
  • 72
  • 219
  • 365
575
votes
7 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
  • 17,922
  • 69
  • 204
  • 352
328
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
  • 101,870
  • 114
  • 239
  • 342
324
votes
11 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
  • 15,556
  • 6
  • 33
  • 36
297
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
  • 11,606
  • 8
  • 61
  • 89
293
votes
12 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
  • 3,805
  • 2
  • 19
  • 11
293
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
  • 4,066
  • 3
  • 24
  • 32
274
votes
8 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
  • 159,905
  • 220
  • 492
  • 726
233
votes
6 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 Meškauskas
  • 20,270
  • 11
  • 71
  • 85
222
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,891
  • 4
  • 21
  • 32
196
votes
2 answers

Differences between git remote update and fetch?

Is git remote update the equivalent of git fetch?
David
  • 2,473
  • 2
  • 18
  • 16
175
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
  • 7,116
  • 4
  • 33
  • 55
1
2 3
25 26