[英]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.