Reputation: 494
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
Upvotes: 1
Views: 52
Reputation: 1324347
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.
Upvotes: 1