Linked Questions
48 questions linked to/from Git: Difference between HEAD, working tree and index?
1903 votes
10 answers
1.6m views
Hard reset of a single file [duplicate]
How do I discard the changes to a single file and overwrite it with a fresh HEAD copy? I want to do git reset --hard to only a single file.
718 votes
9 answers
164k views
How do I merge my local uncommitted changes into another Git branch?
How can I do the following in Git? My current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a ...
503 votes
16 answers
411k views
Why did my Git repo enter a detached HEAD state?
I ended up with a detached head today, the same problem as described in: git push says everything up-to-date even though I have local changes As far as I know I didn't do anything out of the ordinary,...
241 votes
7 answers
64k views
Getting a fatal error in git for multiple stage entries
Using Git version 2.2.0 with unity game engine on OS X, and wanted to commit my code. I added everything and did not get an error message. then commit -m , and got this error message: fatal: ...
308 votes
4 answers
137k views
HEAD and ORIG_HEAD in Git
What do these symbols refer to and what do they mean? (I can't find any explanation in official documentation)
299 votes
4 answers
139k views
How can I have multiple working directories with Git?
I'm not sure if this is something supported by Git, but in theory it seems like it should work to me. My workflow often involves my editing of files in multiple branches simultaneously. In other words,...
198 votes
9 answers
161k views
Why git can't do hard/soft resets by path?
$ git reset -- <file_path> can reset by path. However, $ git reset (--hard|--soft) <file_path> will report an error like below: Cannot do hard|soft reset with paths.
62 votes
5 answers
17k views
What are the differences between these git diff commands?
What are the differences between the following git commands? git diff HEAD git diff HEAD^ git diff --cached or the synonym git diff --staged git diff
33 votes
3 answers
20k views
How to see diff between working directory and staging index?
We can see difference between repository and working directory with: git diff We can see difference between repository and staging index with: git diff --staged But how do we see difference between ...
48 votes
1 answer
26k views
What does "Keep Index" option of Git stash dialog in Intellij IDEA do?
It is said in IDEA documentation Select this check box to have IntelliJ IDEA bring the changes staged in the index to your working tree for examination and testing. Can somebody please explain what ...
24 votes
3 answers
16k views
git reset vs git reset HEAD
Every time a file has been staged, Git offers helpful instructions in the event you needed to unstage a file: (use "git reset HEAD <file>..." to unstage) However the decent Git Tutorials by ...
27 votes
1 answer
40k views
"Proper" way to pull git "production branch" to production server
I'm quite new to Git, and have read the Pro Git book @ http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging. My question is if what I'm doing today is the prefered way to work with ...
28 votes
1 answer
3k views
Why staging directory is also called Index/Git Index?
I was confused the naming of staging directory (Git Index) in Git. Is there any special meaning such that it is called Index? Why not just called Cache / or Temp directory so that we can understand ...
9 votes
3 answers
15k views
How to ignore IDE settings on Git?
I have below Git information and I would like to ignore settings of my IDE (Eclipse). modified: myproject/.classpath modified: myproject/.project modified: myproject/.settings/com.google.gdt....
11 votes
1 answer
11k views
What is the difference between "git checkout -- ." and "git reset HEAD --hard"?
This is not a general question about what '--' does, as in the marked duplicate. This is a git-specific question asking for clarity on what the operational differences are between the mentioned ...