Squashing and Rebasing before submitting changes

Bstrdsmkr

New member
Mar 16, 2012
763
0
0
1. Make a backup of your project directory just in case something goes wrong

2. Add the origin repository (Eldorado's) as an upstream: Right click on your fork in the Windows client and select "Open shell here." In the shell, run the following:
Code:
git remote add upstream git://github.com/Eldorados/script.module.urlresolver.git
3. Roll back to the last common commit. Back in the windows client, look down the list of commits to find the last one your local copy and the upstream have in common. In this case, it should be the the one closest to the top with Eldorado's name on it. After clicking on that commit, above the list of changed files, click "Roll back to this commit."

4. Set aside or "Stash" all your commits. Back in the shell, run the following:
Code:
git stash
5. Fast forward your local repo to match the upstream. In the shell, run the following:
Code:
git fetch upstream
git merge upstream/master
Your local repo should now match Eldorado's

6. Take your changes out of stash and apply them to your newly updated local copy. In the shell, run the following:
Code:
git stash apply
At this point, it'll either complete successfully, or complain about merge conflicts. If it completes successfully, commit your changes, sync them and open a new pull request.

If it complains about merge conflicts, in the shell, run the following:
Code:
git status
This will list any files with conflicts. For each file in the list, open it in a text editor and you'll find that git has edited the file to show both sets of changes. It should look something like this:
Code:
blah balh bhal
line 2 blase bla
<<<<<<<<<<<<<<<<<
def lorem_ipsum():
    do_work
=================
def lorem_ipsum():
    do_better_work()
>>>>>>>>>>>>>>>>>
Edit the file to be valid code again, choosing which function to keep or how to merge them, then save it. Back in the shell, run the following:
Code:
git add c:\path\to\file\edited_file.py
Once you've finished editing all the conflicted files and adding them back to the list, run the following:
Code:
git commit
Then sync your changes, and open a new PR

NOTE: This is temporarily specific to Vinnydude's urlresolver issue. I'll clean it up and make it useful when I get time
 

Bstrdsmkr

New member
Mar 16, 2012
763
0
0
Also, to be picky, this isn't the process for an actual rebase, but I don't know the state of your local repo so this should be safer and it'll do what Eldorado needs to get it to merge
 

Eldorado

Moderator
Staff member
May 7, 2012
990
0
16
Not working right yet? :)

Git can be a pain sometimes until you get very comfy with it.. it took me about an hour to get urlresolver up to date on both branches.. and now there might need to be a 3rd branch for the upcoming Gotham! erg..
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Going to give it another try now. If this doesn't work, I think it might be a lot easier to delete my fork and then i'll just re commit what i've done to the updated version.
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Right, my first problem is when I do:

Code:
git merge upstream/master
It says:

Code:
error: the following untracked working tree files would be overwritten by merge:

                                   lib/urlresolver/plugins/cyberlocker.py
                                   lib/urlresolver/plugins/movreel.py
                                   lib/urlresolver/plugins/rpnet.py
                                   lib/urlresolver/plugins/vidhog.py
Please move or remove them before you can merge.
And how come rpnet is there? I've not done anything with that! >_<
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Is there any need for this to be so un-user friendly?!

I've managed to get right through to the very end right up to the last sync then the pull.

the sync throws up an error, tells me to check it in shell, then git status shows no errors. And the pull still won't pull.

Really loosing my patience with this. :(
 

Bstrdsmkr

New member
Mar 16, 2012
763
0
0
What does the error say? I'm guessing you had to fix some merge conflicts.

It's not so bad once you're used to how it all works. It's a lot like learning a new programming language.
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Code:
loading commits failed

failed to load commit history for this repository. You might need to open a shell and debug the state of this repo.
then git status says:

Code:
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

C:\GitHub\script.module.urlresolver [(87c8ad5...)|REBASE +1 ~0 -0 | +1 ~0 -0 !]>
 git status
# Not currently on any branch.
# You are currently rebasing.
#   (fix conflicts and then run "git rebase --continue")
#   (use "git rebase --skip" to skip this patch)
#   (use "git rebase --abort" to check out the original branch)
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add <file>..." to mark resolution)
#
#       both added:         lib/urlresolver/plugins/movreel.py
#
no changes added to commit (use "git add" and/or "git commit -a")
C:\GitHub\script.module.urlresolver [(87c8ad5...)|REBASE +1 ~0 -0 | +1 ~0 -0 !]>
 

Bstrdsmkr

New member
Mar 16, 2012
763
0
0
Ahh looks like you started an actual rebase. Check movreel.py to see if it's marked any conflicts, fix them if needed, then "git add" it and "git rebase --continue"
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Did all that and then it was just conflict central. Kept pulling up files I'd not even changed, tried resolving those conflicts, got it down to it telling me I had no conflicts and to carry on with the rebase, and then it told me there was no commits to make and I couldn't continue. I hit git status, it told me everything was fine.

Is it not going to be easier for me to completely delete my fork (with my codes backed up of course), get a new fork, which is up to date and then do a pull request of everything form there?
 

Bstrdsmkr

New member
Mar 16, 2012
763
0
0
I think you can do that, but you'll lose all your commit data on github. It'll look like you just created the fork today
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
It's so frustrating cause I know exactly what i'm trying to achieve and what is supposed to be happening, but it keeps throwing up stuff that to me has no relevance to anything I've done! Like it keeps throwing up conflicts about realdebrid and veeHD and I've not even changed them!

It makes no sense at all in the slightest, and having to do it all in shell and having no sort of visual confirmation of anything you are trying to do or where you are up to is ridiculous.

It's almost making me wonder why I bothered spending the time to learn and code the resolvers in the first place :'(
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
I'm going to give this another try when I get back from work later, I've got a few things I want to try.

First off though Bstrd, in step 3 when you say 'find the last one your local copy and the upstream have in common', how is the best way to do that? I ended up going into the graphs on github and working it out from there, but the way I did it didn't feel like I was doing it right at all! lol

If you could clarify the best way to check that would be great :)

As for the files I've been having problems with, i'm going to grab the most up to date versions of El's fork and replace mine with them, that way I've done half the rebase for it!

But yeah, if you could clear up the best way to do step 3 for me that would be great!!! Just in case i've ballsed something up really early on! :p
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Just asked Eldorado to delete the fork I'm on so i can get a fork from the current up to date master.

There was so many different forks it was trying to unravel that it was rediculous. It was pulling up all sorts of files for having conflicts due to other people having updated them and I didn't have a clue what was to keep or discard.
 

Eldorado

Moderator
Staff member
May 7, 2012
990
0
16
Got your new pull request, looking good now :)

Would be good if we can iron out this process a bit more, I know I've had to get Bstrdsmkr to rebase a couple of his pulls already.. sometimes I get multiple pull requests at a time and they could conflict with each other, so I try to merge the most logical one first but then that means I break the 2nd pull request.. and trust me I don't want to merge this stuff manually :)
 

Vinnydude

Developer
Jan 11, 2013
486
0
0
UK
Oh thank F**K for that! You have no idea how relieved I am to hear that :D

And yeah, it was unbelievably complicated!!!

I think good practice would be to rebase before doing any commits, that way everything is up to date. I'll defiantly be doing it this way round in future anyway! lol