是否有办法执行 未经存放地就对存放处进行突击检查?
例如:git /home/repolog
?
请不要告诉我<条码>cd。 页: 1
是否有办法执行 未经存放地就对存放处进行突击检查?
例如:git /home/repolog
?
请不要告诉我<条码>cd。 页: 1
Try:
git --git-dir=/home/repo/.git log
重要的是,要给您的存放地目录提供一切途径。 否则,你只能得到一个错误的信息,即:
fatal: Not a git repository
使用<条码>-C作为第一种理由:
git -C /home/repo log
Per docs,其效果是:
-C <path>
如同在<代码><path>而不是现行工作名录上开始使用。 ......
This is almost equivalent to --git-dir
and --work-tree
without appending the usual .git
folder. However, the options --git-dir
and --work-tree
do not exist to access the repository from outside the work tree; they are used to move the .git
somewhere else, and they are much more complicated to use in some cases.
For instance, to get the log of /home/repo/subdir
only:
git -C /home/repo/subdir log .
or
git -C /home/repo log subdir
It is not possible to use log .
with --git-dir
or --work-tree
. The path must be processed to extract the subpath relative to the top of the work tree, and even in that case, git will not recognize it as a path if you do not use the --
option, so the only possible way is:
git --git-dir /home/repo/.git log -- subdir
Furthermore, --work-tree
does not work at all with the log
subcommand with my version (git 1.9.1). It is just ignored:
git --git-dir /home/repo/.git --work-tree /home/repo/subdir log -- subdir
git --git-dir /home/repo/.git --work-tree /home/repo/whatever log -- subdir
I do not even understand if this is a bug or a feature... as usual with many git design choices.
In fact you need to use --git-dir and --work-tree together. Here is an example:
local [] Desktop: mkdir git
local [] Desktop: cd git
local [] git: touch README.txt
local [] git: git init
Initialized empty Git repository in /Users/albert/Desktop/git/.git/
local [] git: cd ..
local [] Desktop: git --work-tree=git --git-dir=git/.git add .
local [] Desktop: git --work-tree=git --git-dir=git/.git commit -a -m initial commit, called from outside the git directory
[master (root-commit) ee951b1] initial commit, called from outside the git directory
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.txt
local [] Desktop: cd git
local [] git: git log --pretty=oneline
ee951b161053e0e0948f9e2a36bfbb60f9c87abe initial commit, called from outside the git di
I have tried many times! I finally got it!
git - C 继承 --no-pager log --format= %an -1 filename
do remember, please don t add .git to your
- C 继承
对于任何上级指挥,你可以:
git --git-dir=<PATH-TO-REPO>/.git --work-tree=<PATH-TO-REPO> <git-command>
例如,如果你想做某种身份的话:
git --git-dir=/home/myrepo/.git --work-tree=/home/myrepo/ status
或者如果你想要检查分行,寄回的地址是:
git --git-dir=/home/myrepo/.git --work-tree=/home/myrepo/ rev-parse --abbrev-ref HEAD
这类似于@max的答复。 不幸的是,我不做我所需要的事。 --git-dir
。
There s two repos, one inside the other but not a submodule; the outer repo ignores it:
tools (outer repo)
gcc/4.9.2 (inner repo)
What I wanted was the output of git rev-parse --show-prefix
relative to the outer repo. Here s what I came up with (bash syntax; split across lines for readability):
prefix_dir=$(cd ..; git rev-parse --show-toplevel)
prefix_dir=$(GIT_WORK_TREE=${prefix_dir} git rev-parse --show-prefix)
When executed from within 4.9.2 it produces the string gcc/4.9.2
.
Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...
I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...
I have a svn repo with various apps as subdirectory of a single svn repo. That worked because I could have checked out a partial, repo. As I cant do that with git obviously I need multiple repos. I ...
I understand how to merge branches together in git, and I love how easy it makes it. I have a branch that looks like this: project/ |--subproj1/ | |---(files) | |--subproj2/ |---(files) A ...
We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...
I get this on every git svn command I try. I am using git version 1.6.4.2 on OS 10.6 The initial git svn fetch works, and i can do further fetches after that, but they do not enter the log or update ...
Given I have a master branch and a other branch. In the other branch are files I don t want to commit (e.g. log files) so I ignored them in .gitignore. When I switch to the master branch, these ...
Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...