简体   繁体   English

为什么 stash all 命令在命令行(Windows)中不起作用:git --git-dir=c/a.git --work-tree=c/b status -a?

[英]Why stash all command won't work in command line (Windows): git --git-dir=c/a.git --work-tree=c/b status -a?

I am trying below git command referring to this documentation https://git-scm.com/docs/git .我正在尝试参考本文档https://git-scm.com/docs/git 的git 命令。 It works fine if I use stash instead stash -a in below git command, else it shows error message mentioned below.如果我在下面的 git 命令中使用stash而不是stash -a ,它工作正常,否则它会显示下面提到的错误消息。 Can anyone help me with the alternatives to make it work per my need?任何人都可以帮助我找到替代方案以使其根据我的需要工作吗?

My requirement is to stash all files including untracked (if any) before I want to take a git pull, I have multiple projects, for which I want to automate this task because for each project repeating git stash -a , then git pull origin master-ci is the headache, somehow I want to automate this in git-pull-latest.bat script.我的要求是在我想进行 git pull 之前存储所有文件,包括未跟踪的(如果有),我有多个项目,我想为此自动化此任务,因为对于每个项目重复git stash -a ,然后git pull origin master-ci令人头疼,不知何故我想在git-pull-latest.bat脚本中自动执行此git-pull-latest.bat

Git command tried:尝试过的 Git 命令:

set MY_REPO=C:\Users\ravibeli\Documents\Projects\GitRepo
set MY_GIT_OPERATION=pull origin master-ci

git --git-dir=%MY_REPO%\demo-service\.git --work-tree=%MY_REPO% stash -a && git --git-dir=%MY_REPO%\demo-service\.git --work-tree=%MY_REPO% %MY_GIT_OPERATION%

Error message:错误信息:

Ignoring path demo-service/
Saved working directory and index state WIP on poc-branch: 9f625aa18 Merge pull request #1004 in demo-service from ~ravibeli/demo-service:display-message to poc-branch

Instead of trying and automate stash expicitely, you could activate autostash :您可以激活 autostash ,而不是明确地尝试和自动化存储:

git config --global pull.rebase true
git config --global rebase.autoStash true

But if you do not want to rebase on each pull, and do want the classic fetch + merge done by a regular git pull , you can set with Git 2.27:但是,如果您不想在每次拉取时重新设置基础,并且希望通过常规git pull完成经典的fetch + merge ,则可以使用 Git 2.27 进行设置:

git config --global merge.autostash true

In both cases, a git pull will first stash any work in progress from your current working tree.在这两种情况下, git pull将首先隐藏当前工作树中正在进行的任何工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git --git-dir="$HOME/.git/" --work-tree="$HOME" status - 失败并显示 bash:没有这样的文件或目录 - git --git-dir="$HOME/.git/" --work-tree="$HOME" status - fails with bash: No such file or directory 如何在smartgit中设置--work-tree或--git-dir? - How to set --work-tree or --git-dir in smartgit? 使用gulp-git时如何使用git-dir和工作树 - Using gulp-git how to use git-dir and work-tree when 使用--git-dir和--work-tree选项时参数来源/主语含糊 - Ambiguous argument origin/master when using --git-dir and --work-tree options Git 错误“致命:GIT_WORK_TREE(或 --work-tree=<directory> ) 不允许不指定 GIT_DIR (或 --git-dir=<directory> )” - Git error "fatal: GIT_WORK_TREE (or --work-tree=<directory>) not allowed without specifying GIT_DIR (or --git-dir=<directory>)" 通过--work-tree在别处获取git存储库的树,同时保持--git-dir存储库不被修改 - Obtain a git repository's tree elsewhere via --work-tree while keeping --git-dir repository unmodified 在TortoiseGIT上设置git-dir和git-work-tree - Setup git-dir and git-work-tree on TortoiseGIT 其他服务器上的Git工作树 - Git work-tree on other server 是否支持在 a.git 文件中指定工作树? - Is specifiying a work-tree in a .git file supported? 我可以拉一个git工作树吗? - Can I pull a git work-tree?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM