Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get another branch instead of default branch with go get

Tags:

git

github

go

I have 2 repositories. Let say them repo_a and repo_b. I imported repo_a in repo_b

When I ran go get, it will get repo_a master branch. Is there any way to get develop branch using go get or another command from repo_b?

I do not want to git pull on each specific package (in this case repo_a)

like image 686
MouseWanted Avatar asked Mar 13 '17 10:03

MouseWanted


People also ask

How do I change my default branch to another?

Under your project repo, select Branches. On the Branches page, select More options next to the new default branch you want, and choose Set as default branch. After you set the new default branch, you can delete the previous default if you want.

How do I fetch a different branch?

just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.


1 Answers

Starting with Go 1.11, this is possible when using Go modules. When installing a dependency for a Go module, you can specify a module query which may contain a branch or tag name:

$ go get <path-to-repo>@<branch> 
like image 157
helmbert Avatar answered Oct 01 '22 12:10

helmbert