1

Is it possible to push to remote branch directly ?

This is scenario:

There is branch on github repo lets call it X, I cloned project to my local repo, when i type:

git checkout origin/x

I get text in terminal saying: "You are in 'detached HEAD' state ... If you want to create a new branch to retain commits you create ... git checkout -b new_branch_name".

So i create new branch, do my job, make commit and push it to remote github repo with folowing command:

git push -u origin name_of_my_branch

That comand created branch on github repo, so now i am able to make pull request to that online branch, so again i am wondering is it possible to sync this branch directly with remote branch(x) and push to that branch(x) directly, without pull requests ?

vlsim
  • 31
  • 3

2 Answers2

0

You can push directly to the remote branch:

git push -u origin x
Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
0

git will automatically track the local branch to the remote one if you just "git checkout x". Don't prefix it with "origin/" or you will get the "detached head" message.

fedup
  • 1,209
  • 11
  • 26