简体   繁体   中英

Git subtree - subtree up-to-date but can't push for Windows

My Subtree says it's up to date, but I can't push new files

git subtree pull --prefix=CASE-SENSITIVE-PATH-TO-FOLDER remote-alias master

I am following Git subtree - subtree up-to-date but can't push .

But need a solution that works only for windows. The one provided does not work.

Error:

! [rejected] d6a4b0aef2c196a0d80177a96586dd1e6f3c8544 -> master (non-fast-forward)

error: failed to push some refs to ' https://repourl/repo.git '

hint: Updates were rejected because a pushed branch tip is behind its remote

hint: counterpart. Check out this branch and integrate the remote changes

hint: (eg 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Here is what I've tried

git subtree split --prefix path-to-folder master

Executing the above code gives me the following error

Error:

fatal: ambiguous argument 'master': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [< revision>...] -- [< file>...]'

Running both below work, they both give me the token 'd6a4b0aef2c196a0d80177a96586dd1e6f3c8544', but I am having trouble trying to figure out how to "force" the branch

git subtree split --prefix CASE-SENSITIVE-PATH-TO-FOLDER

git subtree split --prefix CASE-SENSITIVE-PATH-TO-FOLDER -b master

So this is what worked after much digging.

Looking at @aednichols's comment I found:

git push <your subtree's origin> `git subtree split --prefix=Path/to/subtree`:master --force

so here is my bat file.

for /f "delims=" %%a in ('git subtree split --prefix CASE-SENSITIVE-PATH-TO-FOLDER') do @set token=%%a
git push https://repo/repo.git %token%:master --force
pause

If using something other than master add the subtree dir

git subtree split --prefix CASE-SENSITIVE-PATH-TO-FOLDER -b subtreedir

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