Git diff without checkout branch
As an example:
In the kernel source code, it has a lot of tags. I can diff them, such as:
git diff v2.6.37-rc3 v2.6.38-rc4
and I get the right output.
Now I copy .git
directory to another place, and in this new .git directory, I can also use
git diff v2.6.37-rc3 v2.6.38-rc4
to get the right output.
But, I have another branch such as "mydev". I can't checkout to this mydev branch, and do the git diff v2.6.37-r开发者_JAVA百科c3 v2.6.38-rc4
commmand.
How can I do it?
You can' t just copy the .git directory of a non-bare GIT repository and expect to be able to checkout branches. When non-bare, the repository has an index and needs a corresponding working directory. Note that some GIT commands and arguments (like 'diff' with two commits) operate only on the repository objects/commits and thus don't need a working directory - hence they work, as you've seen. But other commands (like 'diff' between on commit and the working directory) need the working directory.
You should get the same output as before. Having a branch in the repository should not matter.
精彩评论