1

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?

Jayram
  • 18,820
  • 6
  • 51
  • 68

2 Answers2

0

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)
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @Jayram sorry: `git branch -avvv` (`git br` is an alias I use ;) ) – VonC Aug 29 '13 at 06:13
  • Please check the update in my question. As I am unable to push to my fork. – Jayram Aug 29 '13 at 06:14
  • origin https://github.com/user_name/repo.git (fetch) origin https://github.com/user_name/repo.git (push) – Jayram Aug 29 '13 at 06:28
  • @Jayram maybe your branch is set to push to a different upstream repo for which you don't have any write access. Try a `git push origin yourBranch`. – VonC Aug 29 '13 at 06:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/36438/discussion-between-jayram-and-vonc) – Jayram Aug 29 '13 at 06:42
  • @Jayram chat is blocked at work :( Amend your question with the additional information you got so far. – VonC Aug 29 '13 at 06:43
  • yeah I did that still it pushed it to the branch of master not to my fork – Jayram Aug 29 '13 at 06:45
  • @Jayram and `git push origin yourBranch:YourBranch`? That should force the creation/update of `YourBranch` on origin. Note that "fork" is rather used for a "forked" repo, not a branch. – VonC Aug 29 '13 at 06:47
0

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/

Camille
  • 86
  • 1
  • 5
  • I did not made a branch. I have no idea how i was pushing to master. As I don't have access rights to update the master. It automatically created a branch and pushed the code to that. Now if I am pushing anything it goes to that branch not to my fork. – Jayram Aug 29 '13 at 06:30
  • when you type git status are you on master? – Camille Aug 29 '13 at 06:30