-5

I am currently on the branch(f1) other than main. What command should i use to push the changes to it

evileye
  • 18
  • 8
  • 3
    Does this answer your question? [Git for beginners: The definitive practical guide](https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide) – flaxel Nov 02 '20 at 08:13
  • 1
    It depends on your config. Also, this is way too vague and confused, could you elaborate? – Romain Valeri Nov 02 '20 at 08:15
  • 1
    Otherwise you can follow this [post](https://stackoverflow.com/a/1519032/10951752). – flaxel Nov 02 '20 at 08:15
  • 1
    I suppose you are trying to push to a remote branch. Then you can choose the branch to which you want to push to: `git push origin f1:f1` will push to remote's f1 whereas `git push origin f1:master` will push to remote's master. Please read about remote branches first: https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches – Peaceful Nov 02 '20 at 08:16
  • What will Git push origin f1:f1 do ? – evileye Nov 02 '20 at 08:28
  • @devil : it will push your local branch f1 to your remote branch f1. As I said, please read about remote branches. – Peaceful Nov 02 '20 at 09:00

1 Answers1

1

to push on f1:

git push -u origin f1

to push on main:

git push -u origin main
Tasnuva Leeya
  • 2,515
  • 1
  • 13
  • 21
  • What is -u here? Can you elaborate it – evileye Nov 02 '20 at 08:30
  • 1
    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 https://stackoverflow.com/questions/5561295/what-does-git-push-u-mean/30707017 – Tasnuva Leeya Nov 02 '20 at 08:32
  • @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. – Peaceful Nov 02 '20 at 09:02
  • good point. in that case both local and remote branch should be mentioned something like main:temp. – Tasnuva Leeya Nov 02 '20 at 09:07