Reputation: 14856
At a certain point in my Travis-CI deployment process I want to merge a set of files from a different branch in the same repo.
Unfortunately, I can't figure out how to do this. Simply setting up a bash script to run commands like git checkout origin master
gives me errors like:
error: pathspec 'origin' did not match any file(s) known to git.
error: pathspec 'master' did not match any file(s) known to git.
So my question is: how can I get my hands on files from another branche in Travis?
Thanks
Upvotes: 1
Views: 217
Reputation: 14856
The problem is that Travis is not aware of other branches on origin and doesn't have copies of them locally. You have to run git fetch
to resolve this:
git fetch --depth=1 [email protected]:your-org/your-repo.git refs/heads/other-branch:refs/remotes/origin/other-branch
This command tells git fetch
to copy the branch at refs/heads/other-branch
to the local machine at refs/remotes/origin/other-branch
Once you've done this you will then be able to get your hands on files from other-branch
using standard git commands.
Upvotes: 1
Reputation: 30212
Remote branches are referred to like this: the-remote/the-branch... so you need to say something like: git checkout origin/master
. It also works for a lot (if not all?) operations.... diff, cherry-pick, rebase, merge, etc etc
Upvotes: 0