Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I never used git before GitHub released the Windows app, so I've never used it in command line.

So here's my situation:
I did some commits on master, then switched branch and did some commits there too. All without pushing to GitHub. When I then clicked sync in the the windows app (which I assume does git push), to my surprise, all my commits were pushed to my new branch - even the commits I made while I was in master.

Since this is the behavior of the windows app, I guess I have to use the command line.
What is the correct git push command to push the commits to the correct branches on the remote?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
935 views
Welcome To Ask or Share your Answers For Others

1 Answer

To push all branches (refs under refs/heads), use the following command (where origin is your remote):

git push origin --all

You can also set push.default to matching in your config to push all branches having the same name on both ends by default. For example:

git config --global push.default matching

Since Git 2.0 the default is simple which is the the safest option.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...