1

Trying to get to grips with Git(Hub)

So I forked this project on github https://github.com/philipmat/discogs-xml2db to give https://github.com/ijabz/discogs-xml2db

I create a local repositoy from this, and created a branch I made some changes and pushed to my remote repository. I then created a pull request to get these changes into the philipmat repository.

The pull request was merged as https://github.com/philipmat/discogs-xml2db/pull/22 and it advised me that I could now delete the branch I created.

So far so good, but when I look https://github.com/ijabz/discogs-xml2db i cant see my changes, even though it says

This branch is 0 commits ahead and 0 commits behind master

So what is the missing step I haven't done ?

* Solution *

Using the answers below I did the following (starting again) which I document in detail (more for my own reference then anyone else):

git clone https://github.com/ijabz/discogs-xml2db.git
cd discogs-xml2db
git remote add upstream https://github.com/philipmat/discogs-xml2db.git
git pull upstream master
git push

In english this means

  1. Create local version of my remote repository

  2. Go into this repository

  3. Create a reference to philipsmats (the project owners) remote repository

  4. Pull anything from the philipsmats master branch that isnt in my local repos (master branch)

  5. Push anything in my local master branch to my remote master branch (if not there)

So to summarise to get changes from one remote repository to another remote repository I have gone via my local repository (im surpised not possible to go direct from one remote repos to another via github)

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • Good feedback. Github doesn't allow direct pull between repos for now, since the potential merge conflicts wouldn't be solved by github alone. It is best that this update process is initiated locally by the user, and push back to github once done. – VonC Jun 05 '14 at 08:43

2 Answers2

0

0 commits ahead and 0 commits behind master

That is behind the last known state of master from the original repo.

You should locally:

git checkout master
git pull upstream
git push

Assuming that:

upstream vs. fork

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • but it says '0 commits ahead and 0 commits behind master' on Github - but surely github knows the current status of master ? – Paul Taylor Jun 03 '14 at 08:30
  • @PaulTaylor no: it knows the status of the master you used for your fork: if the original repo has new commits, your fork won't compare master to those. I have multiple old forks (like https://github.com/VonC/go-github) which are all "`0 commits ahead and 0 commits behind master`". It is a best practice to not push anything to `master` anyway on a fork. – VonC Jun 03 '14 at 09:18
  • @PaulTaylor if you want to update the master of your fork, follow the steps I describe in my answer, and you will see the PR merged changes. – VonC Jun 03 '14 at 09:18
  • Hmm, this is why I have resisted git for so long, I like the concept of distributed source control but git seems to needlessy complex. My intended workflow was I take the latest code , I raise issues for anything that needs improving, if I fix an issue I request that gets put into original repo and then if it does I update my repo from the original repo. Unfortunately although Im sure it is correct I don't really understand your answer – Paul Taylor Jun 03 '14 at 10:48
  • @paul my answer is about updating your master branch locally, before pushing it to your fork: simple. – VonC Jun 03 '14 at 10:57
  • I did git pull https://github.com/philipmat/discogs-xml2db okay but git push fails with authentication error even though I'm logging in with correct username and password – Paul Taylor Jun 03 '14 at 13:18
  • @paul check what git remote -v returns: does "origin" reference your fork https url? Note that you will have to enter your login/password: being logged in on the GitHub site has nothing to do with the authentication when doing a git push. – VonC Jun 03 '14 at 13:22
  • no origin is linked with the original philipm repo, no idea why – Paul Taylor Jun 03 '14 at 13:24
  • @paul that is your problem right there. See the link I mention in my answer. git remote set-url allows you to change the url associated with a remote, like origin. – VonC Jun 03 '14 at 13:27
  • @PaulTaylor as you can see on the diagram, origin is associated to your fork. – VonC Jun 03 '14 at 13:28
  • I think I must have cloned the philip repos rather than my fork, I did't realize that was wrong. Okay thanks for your help but I'm just going to delete my local repos and start all over again, I that would be easier. – Paul Taylor Jun 03 '14 at 14:01
  • FYI Ive added an solution for dummies to my questions based on your answers, thanks. – Paul Taylor Jun 05 '14 at 08:39
0

Because you are browsing the master branch, and your forks master branch is not up to date. You did your changes on the issue19 branch. If you press W then search for issue19, you'll see it. (unless you deleted that branch on your fork)

In order to reflect the changes from the other repository, you'll have to pull and rebase.

Let original be philipmat/discogs-xml2db and origin be ijabz/discogs-xml2db

$ git fetch original
$ git checkout master
$ git pull --rebase original master
$ git push

Now your remote and local will be up to date with philipmat/discogs-xml2db

ddavison
  • 28,221
  • 15
  • 85
  • 110
  • I did delete the branch because github told me it was al merged and I no longer needed it, thanks for your answer but is there a way to update my master branch from within github itself ? – Paul Taylor Jun 03 '14 at 07:44