Test Github Push Request
I recently had to test a Pull Request so I thought I'd document how to do it for others.
First there's going to be lots of users and addresses so I'll save everyone the headache of cut/paste/edit/cut/paste by using a few environment variables.
REPO="docker-tor-browser"
MY_USER="DomiStyle"
PR_USER="Bootsektor"
First clone a fresh copy of our repo:
git clone git@github.com:$MY_USER/$REPO.git $REPO-$MY_USER
and move into the new folder:
cd $REPO-$MY_USER
The first thing we need to do is add a reference to the repo we want to take changes from:
git remote add repo-$PR_USER git@github.com:$PR_USER/$REPO.git
Next we will fetch the code from the remote repo's branch in this case master
:
git fetch repo-$PR_USER master
We can check to make sure it has arrived with:
$ git branch -r
repo-Bootsektor/master
origin/HEAD -> origin/master
origin/master
We can see from git branch
that it is not a local branch yet:
$ git branch
* master
So we must check it out on to a local branch:
git checkout -b repo-$PR_USER-master repo-$PR_USER/master
Viewing the local branches shows that we now have a local branch and we have switched to it:
$ git branch
* repo-Bootsektor-master
master
You can now test the new branch before the actual merge. First change any references to the remote repo:
$ grep -i $PR_USER `find . -type f |grep -v ./.git`
./README.md:https://github.com/Bootsektor/dock...
./README.md: docker run -d -p 5800:5800 bootsektor/tor-browser
Edit and commit the changes on to repo-$PR_USER-master branch.
Personally, I like to do a full diff outside of git to make sure everything is as it should be. Sometimes, it's hard to see when files have been deleted or renamed, so a tree view is very helpful.
$ kdiff3 $REPO-$MY_USER-master $REPO-$PR_USER-master
Next checkout the branch you would like to merge this branch into:
git checkout master
Penultimately, merge the whole branch in as one commit. This makes it easier to remove it later is something is not right.
git merge --squash repo-$PR_USER-master
We can see the new files have been added but are not committed yet.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
modified: Dockerfile
modified: README.md
modified: browser-cfg/mozilla.cfg.template
modified: screenshot.png
Finally, we can commit the whole branch in one go with a nice message to say what we have done:
$ git commit -m"Merge of Push Request 63"
Don't forget to push the changes!
$ git push
No feedback yet
Form is loading...