Currently I'm using this alias to fetch master in the background and then switch to it. This way Visual Studio works the fastest for me:
[alias]
fetch-checkout = !git fetch -p && git fetch origin master:master && git checkout master
What I'd like to do on top of that is to capture current branch name and delete it afterwards.
Is it possible on Windows?
Since you can't delete a branch you're currently on, you would need to use some kind of temporary storage for the old branch's name. Something like:
git rev-parse --abbrev-ref HEAD > tmp.txt && git checkout master && git branch -d `cat tmp.txt` && rm tmp.txt
would work, but you'd need to make sure you're not overwriting anything with the > tmp.txt
https://stackoverflow.com/a/12142066/7976758
Q: How to get the current branch name in Git?
A: git rev-parse --abbrev-ref HEAD
[alias]
fetch-checkout = !curbr=$(git rev-parse --abbrev-ref HEAD) && git fetch -p && git fetch origin master:master && git checkout master && git branch -D $curbr
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.