Linked Questions

1903 votes
10 answers
1.6m views

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.
Emiliano's user avatar
  • 24.2k
718 votes
9 answers
164k views

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 ...
solsberg's user avatar
  • 8,105
503 votes
16 answers
411k views

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,...
Adam Bergmark's user avatar
241 votes
7 answers
64k views

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: ...
Daniel Toebe's user avatar
  • 2,719
308 votes
4 answers
137k views

What do these symbols refer to and what do they mean? (I can't find any explanation in official documentation)
collimarco's user avatar
  • 35.7k
299 votes
4 answers
139k views

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,...
jtolds's user avatar
  • 3,559
198 votes
9 answers
161k views

$ 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.
yao's user avatar
  • 2,073
62 votes
5 answers
17k views

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
Matthew Rankin's user avatar
33 votes
3 answers
20k views

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 ...
matori82's user avatar
  • 3,849
48 votes
1 answer
26k views

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 ...
Carter's user avatar
  • 10.9k
24 votes
3 answers
16k views

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 ...
skube's user avatar
  • 6,255
27 votes
1 answer
40k views

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 ...
dropson's user avatar
  • 1,121
28 votes
1 answer
3k views

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 ...
Kit Ho's user avatar
  • 27.2k
9 votes
3 answers
15k views

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....
Cataclysm's user avatar
  • 8,857
11 votes
1 answer
11k views

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 ...
M_M's user avatar
  • 2,135

15 30 50 per page