Create a temporary branch name with git

A bit related to this question I would like to work with a temporary branch in a shell script.

a few lines:

cd $(git rev-parse --show-toplevel) &&
git subtree split --prefix=some_subfolder -b temp &&
git push my_remote temp:publication_branch -f

Now I'm not sure what this will do if the branch tempalready exists, in any case I do not want the result to my_remote/publication_branchdepend on this. And I also do not want to change the branch temp(assuming that I have it for something unrelated). At best, I will also do the cleaning at the end

cd $(git rev-parse --show-toplevel) &&
git subtree split --prefix=some_subfolder -b temp &&
git push my_remote temp:publication_branch -f
git branch -D temp

So what I'm looking for is a way to create a temporary branch name that doesn't exist yet, similar to mktemp? Is there a git command that can create a temporary branch name?

+4
source share
1

split -b, ( ):

stdout . HEAD , , .

,

split_head=`git subtree split --prefix=some_subfolder`
git push my_remote "$split_head":publication_branch -f
+3

Source: https://habr.com/ru/post/1685440/


All Articles