I am currently on the branch(f1) other than main. What command should i use to push the changes to it
1 Answer
to push on f1:
git push -u origin f1
to push on main:
git push -u origin main
4 Comments
evileye
What is -u here? Can you elaborate it
Tasnuva Leeya
The -u option automatically sets that upstream for you, linking your repo to a central one. That way, in the future, Git "knows" where you want to push to and where you want to pull from, so you can use git pull or git push without arguments. to know more see this thread stackoverflow.com/questions/5561295/what-does-git-push-u-mean/…
Peaceful
@Tasnuva : there is a small caveat here though: git push -u origin main works only if branch main exists on the remote and you have right to push to it. You may have a local main branch which you may want to push to remote's temp branch in such situation.
Tasnuva Leeya
good point. in that case both local and remote branch should be mentioned something like main:temp.
git push origin f1:f1will push to remote's f1 whereasgit push origin f1:masterwill push to remote's master. Please read about remote branches first: git-scm.com/book/en/v2/Git-Branching-Remote-Branches