Learning Git Work Processes in DW

Written on April 13, 2017

Today I intended to spend the entire day working on low-hanging fruit for dw-free repos on GitHub. Dreamwidth is an open source LiveJournal fork that has now become more popular due to current events with upstream (actually, it’s not really an upstream, since LJ is no longer open source). What I found found instead was a merge conflict, which turned into a huge lesson for me and maintaining pull requests in a community project.

First, the day prior, I was working on an issue of adding Medium to DW profiles 2110. This was an old issue. And I did the regular push into develop branch without a thought.

The next day (or today), I decided to pick up a new ticket 2108. Here too I pushed, initially, to the develop branch.

Here intersects two conflicts.

1) GitHub accepted my pushes to develop and organizes it into one pull request.

2) Because I have not updated my develop branch, I was +500 commits behind the current develop branch.

The result was a pull request with merge conflicts that require manual merge conflict resolution. And if you’re a programmer, the words “manual resolution” should scare you.

I thought: “There must be a better way.”

Well, there is.

The first few steps in this article really take you on the right path.

So I thought, I should make a script.

This is for bash, and it requires manual implementation (sorry). But I hope to create an automated script here later. :)

Go to your repos containing the project you want to make a PR to.

Do not make any changes to the code.

If you’ve already made changes, perhaps you should just start over. Remove the local repos, re-fork it on GitHub (delete your fork), and then pull a new local repos without the commits you’ve made.

Or you can try removing the most recent commits you’ve made. More here.

First, make sure you update your repos to meet the current master branch. In this example, we will be using dw-free.

git fetch dreamwidth
git checkout develop && git pull --ff-only dreamwidth develop:develop
git push origin develop

You now have an updated develop branch. You are ready to make your patch branch.

git branch [your new branch name]
git checkout [branch]

Make the changes to your dw-free files.

Add the changes normally.

git add .
git commit -m "[message]"
git push

You will probably receive an error. Just follow the instructions.

Remember to checkout of this branch.

git checkout develop

This way when you update your repos in the future, you will be able to do it in the correct branch.

Go to GitHub. Make a new pull request. Compare the heads of two repos. Add yours to the right. Select the branch you created above.

Then you’re done. Repeat this for the next pull request.

Take me home.

Check out the archive.