I'm writing a test script for a CI/CD system and need to checkout the source and target branches of a pull request and do some verifications.
I would like to have fixed branch names in my local repo (src
and target
) and hence I use refspecs with a target branch for my fetches.
But additionally to my target branch git also fetches into a target branch with the original name of that branch (marked bold below). In the git fetch manpage I didn't even find a hint that git should behave this way.
This issue leads sometimes to name conflicts and I want to avoid that.
+ git fetch --no-tags -f origin feature/some-feature:refs/remotes/origin/src
From github.com:user/repo
* [new branch] feature/some-feature -> origin/src
* [new branch] feature/some-feature -> origin/feature/some-feature
+ git fetch --no-tags -f origin master:refs/remotes/origin/target
From github.com:user/repo
* [new branch] master -> origin/target
* [new branch] master -> origin/master
How can I make git stop fetching into branches with original names from remote and use only the target branch names I explicitly mention (how to remove bold lines)?