简体   繁体   中英

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 . It works fine if I use stash instead stash -a in below git command, else it shows error message mentioned below. 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 command tried:

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 :

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 config --global merge.autostash true

In both cases, a git pull will first stash any work in progress from your current working tree.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM