git push -u origin <branch>
git push -u origin new_branch
git init
# Optional: create branch
git checkout -b branch_name
git add .
git commit -m "Adds existing project to GitHub remote repository"
git remote add origin https://github.com/username/example-project.git
git pull --rebase origin main
# Resolve merge conflicts if needed
git push origin main
git push origin <Branch_Name>
$ git checkout feature
$ git push -u origin feature
$ git push <remote> <branch>
Prior to the introduction of git push -u, there was no git push option to obtain what you desire. You had to add new configuration statements.
If you create a new branch using:
$ git checkout -b branchB
$ git push origin branchB:branchB
You can use the git config command to avoid editing directly the .git/config file:
$ git config branch.branchB.remote origin
$ git config branch.branchB.merge refs/heads/branchB
Or you can edit manually the .git/config file to add tracking information to this branch:
[branch "branchB"]
remote = origin
merge = refs/heads/branchB