简体   繁体   中英

Checking if the push was on master or branch — Github

I just pushed an update on Github. It was successful. When I checked on Github it was not showing. How to check on Github that push was on master or my fork?

Update: I have no access rights to write or push on master. When I checked master branch a new branch was created and my codes were pushed in that branch. Now if I am pushing anything it is going to the branch not to my forked repository. How to overcome this?

You can try:

git remote show origin

That would display the remote ' HEAD branch ':

C:\Users\VonC\prog\git\git>git remote show origin
* remote origin
  Fetch URL: https://VonC@github.com/VonC/git
  Push  URL: https://VonC@github.com/VonC/git
  HEAD branch: master                            <<==============
  Remote branches:
    maint  tracked
    master tracked
    next   tracked
    pu     tracked
    todo   tracked
  Local refs configured for 'git push':
    master forces to master (up to date)
    next   forces to next   (up to date)

This isn't a definitive answer though, because you can see:

  Fetch URL: https://github.com/git/git
  Push  URL: https://github.com/git/git
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    maint
    master

In that case, you need to go to the GitHub repo itself, and see what default branch is set .


Regarding your push, check:

  • git status (to see if you are on a branch, or in a DETACHED HEAD )
  • git branch -avvv (to see which branch is supposed to push to where)

It sounds like you accidentally made another branch and that each branch has unique commits.

You can take the code from the branch you don't want and merge it with the "good" fork. Here is a really fun a simple tutorial that has pictures and is interactive. It will show you exactly what you need to do.

http://pcottle.github.io/learnGitBranching/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM