-5

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

6
  • 3
    Does this answer your question? Git for beginners: The definitive practical guide Commented Nov 2, 2020 at 8:13
  • 1
    It depends on your config. Also, this is way too vague and confused, could you elaborate? Commented Nov 2, 2020 at 8:15
  • 1
    Otherwise you can follow this post. Commented Nov 2, 2020 at 8: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: git-scm.com/book/en/v2/Git-Branching-Remote-Branches Commented Nov 2, 2020 at 8:16
  • What will Git push origin f1:f1 do ? Commented Nov 2, 2020 at 8:28

1 Answer 1

1

to push on f1:

git push -u origin f1

to push on main:

git push -u origin main
Sign up to request clarification or add additional context in comments.

4 Comments

What is -u here? Can you elaborate it
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/…
@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.
good point. in that case both local and remote branch should be mentioned something like main:temp.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.