public
Last active

push existing local branch to remote

  • Download Gist
0. create local branch
1 2 3 4 5
#syntax
git checkout -b name_of_local_branch
 
#example
git checkout -b experimental
1. push local branch
1 2 3 4 5
#syntax
git push my_repo name_of_local_branch:refs/heads/name_of_remote_branch
 
#example
git push origin experimental:refs/heads/experimental
2. create local references
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# syntax
 
mate .git/config
 
[branch "name_of_local_branch"]
remote = my_repo
merge = refs/heads/name_of_remote_branch
 
 
#example
 
mate .git/config
 
[branch "experimental"]
remote = origin
merge = refs/heads/experimental
3. pull existing remote branch and track
1 2 3 4 5 6 7
# syntax
git fetch
git checkout --track -b name_of_local_branch origin/name_of_remote_branch
 
# example
git fetch
git checkout --track -b experimental origin/experimental

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.