2

I have forked a repo from Github and then created a branch named process and i have started working on this repository and i have made 7 commits with slight modifications from the original master on my branch progress .

Now i pushed the changes to the github and it showed me this This branch is 7 commits ahead, 16 commits behind jwasham:master. Now i solved this by checking out my process branch and added upstream

$ git branch --set-upstream-to=origin progress

and then i made rebasing so my changes appear on top of those commits which were made on the original repo and done like this

$ git pull --rebase First, rewinding head to replay your work on top of it... Fast-forwarded process to 266048d8326bde6f1cb137d8b898fc2fff645f94.

But when i tried to push it to the github it showed me

$ git pu
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/uppusaikiran/repo_name.git
   0569dcf..266048d  process -> process

And clearly nothing has changed and still i have same problems This branch is 7 commits ahead, 16 commits behind jwasham:master.

How to approach this problem , where exactly i went wrong and how to update my fork with my changes on top of the updates?

Simplified Question as suggested by many that question was difficult to understand

  • On Github i choose a project
  • I wanted to work on , so i forked
  • I cloned my fork
  • Created a branch progress
  • Started working on the branch
  • Made some tiny changes without effecting any deletions Link to what i have done
  • Commited and pushed to my progress branch
  • In the mean time Owner(Original repo) updated his repo so my fork got outdated with original,but ahead by some commits which are my commits
  • So This left me like this 7 commits ahead 16 commits behind jwasham:master
  • All i wanted to is align with repo commits and also my commits should be on top of updated fork and these commits does not cause conflicts
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
SaiKiran
  • 6,244
  • 11
  • 43
  • 76
  • P.S : I have changed the branch name (very long to short in question) for clear understanding and convenience. – SaiKiran Oct 11 '16 at 10:42
  • This looks like a big mess, one which I doubt I could solve without being at your computer. But one comment: Use `git pull --rebase origin branch` and `git push origin branch` unless you know for certain that the default behavior will give you this. – Tim Biegeleisen Oct 11 '16 at 10:45
  • @TimBiegeleisen nothing changed literally. – SaiKiran Oct 11 '16 at 10:48
  • Why are you adding an upstream in the middle of things? This seems unnecessary and possibly wrong. – Tim Biegeleisen Oct 11 '16 at 10:50
  • @TimBiegeleisen https://github.com/jwasham/google-interview-university is the main repo and i wanted to fork this repo and mark the completed topics,but due to large number of updates i need to keep my fork updated?Do you have any solution to do this in the context of the question. After 3-4 topics completed i would mark them and commit on my fork ,but updates caused my commits to stack up and newer commits on original repo got stuck from pulling.How to rectify this? – SaiKiran Oct 11 '16 at 10:55
  • Small question, do you have two different branches `progress` and `process` or is that a typo? – Jeff Puckett Oct 11 '16 at 11:44
  • @JeffPuckettII typo – SaiKiran Oct 11 '16 at 11:52

1 Answers1

2

When you were doing

$ git branch --set-upstream-to=origin progress

you told git that your local branch progress is tracking origin/progress thus

$ git pull --rebase

is rebasing on origin/progress and not on jwasham:master as you wish.

You need to fetch the changes from jwasham:master into your local clone and then you can do the rebase.

E.g:

$ git remote add jwasham <URL>
$ git fetch --all
$ git rebase jwasham/master

then you can push to your github-clone - most likely with --force if you previously published your branch.

Patrick B.
  • 11,773
  • 8
  • 58
  • 101