0

If I create branches on my local git repos like so:

git checkout -b test

then do a push

git push

I don't actually see the new branch test in my GitHub page. How do I make my remote branches mirror my local branches?

Update

When I made a commit (even though there were no changes) and ran:

git push origin test

that worked. But is that the correct way? Shouldn't a git push push all local changes to the remote repository?

2 Answers 2

2

Use

git push -u origin test:test 

To create the remote branch.

But is that the correct way?

Yes.

Shouldn't a git push push all local changes to the remote repository?

Only if the branch was setup to track to remote branch in the first place. Your branch isn't tracking anything until you explicitly push it once.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice. this worked and told me that the remote branch is now tracking the local branch. But just for the sake of clarity, what does the -u flag do?
@Maiasaura It sets an upstream tracking reference.
0

You have to push new local branches explicitly:

git push origin test:test 

Otherwise Git would push any (temporary) local branch you created3

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.