使用时git add .
使用您所在的实际路径(incase 是一个 git repo)。我将如何使用git add
,git commit
和git push' outside of the working dir? Like
git add /Users/zad0xsis/my-git-repo`。
这能实现吗?
小智 10
我使用该git -C
选项取得了成功。取自Git 文档:
Run as if git was started in <path> instead of the current working directory.
Run Code Online (Sandbox Code Playgroud)
该-C
选项位于您要执行的实际命令之前,这一点非常重要:
Wrong: git add . -C some-path
Correct: git -C some-path add .
Run Code Online (Sandbox Code Playgroud)
根据我的系统(git 1.7.6)上的 git 文档,您可以使用--work-tree
或调整工作目录(代码所在的位置),并使用或$GIT_WORK_TREE
调整存储库目录(git 对象所在的位置)。如果这不起作用,您可以使用包装脚本,例如--git-dir
$GIT_DIR
#!/bin/bash
cd /desired/path
git "$@"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5421 次 |
最近记录: |