Skip to content
Mats Wichmann edited this page Aug 26, 2014 · 2 revisions

Get going in a dash

Contributing to the LSB is easy, but not being familiar with git and GitHub may pose some problems. Thus, here is a quick guide to smooth out those bumps. This is NOT a git and GitHub HOWTO.

1.) Fork

If you want to contribute to the LSB you want to Fork the repo into your own project. This is done by visiting Linux Standard Base repo and then clicking the "Fork" button in the upper right hand corner. This makes a copy in your github project area.

2.) Clone

Once the fork is complete you want to switch to your fork in the web-ui (https://github.com/YOUR_USERNAME/lsb) so it's the active project, and find the box on the right hand side with the label SSH clone URL. Copy the content of the box, should look something like this: git@github.com:YOUR_USERNAME/lsb.git. On your machine in a directory of your choice run git clone git@github.com:YOUR_USERNAME/lsb.git, i.e. use the git "clone" command with the content you copied from the box in the UI. This makes a copy of the tree onto your work machine.

3.) Edit

Before you run off fiddling with stuff there are some steps you can take to make your life a bit easier. Edit .git/config in the lsb directory and add the following:

[remote "upstream"]
    url = git@github.com:LinuxStandardBase/lsb.git
    fetch = +refs/heads/*:refs/remotes/upstream/*

This enables you to have a very simple work flow, outlined below, where you can track the "upstream" project (LinuxStandardBase/lsb) from which you started without potentially messing up your copy of things.

4.) The workflow

4.1) Get your copy up to date

Before you start hacking at anything, remember things may be changing upstream, you want to get your copy up to date. In your lsb directory execute the following commands:

git checkout master
git pull --rebase upstream master
git push origin master

This sequence pulls the latest and greatest from the LinuxStandardBase/lsb repo into your master branch and rebases your master to point to HEAD. After that you push this latest code to your own master branch in your project on GitHub.

4.2) Creating something new

Now you are ready to scratch your itch.

git checkout -b NAME_OF_MY_BRANCH

This creates a branch and you can start hacking away as you please. Once you are done and have everything just the way you want it you'll need to use git add for the files you changed or added and then use git commit to commit the changes to your branch. Provide a good commit message, "change XYZ" is a lousy commit message, the reviewers can see what you changed, they want to know why.

4.3) Push it

Push your branch to your github project

git push origin NAME_OF_MY_BRANCH

4.4) Send a pull request

Log into GitHub and browse to your lsb repository. At the top just above the directory listing you will find a drop down menu with "branch:NAME_OF_MY_BRANCH" as the selected choice. To the right you can create a "PullRequest". Create the pull request to "lsb:master". Once the pull request is submitted the LSB reviewers will be notified.

5.) When it's all done

If your pull request got accepted and is closed clean up your tree.

git checkout master
git branch -D NAME_OF_MY_BRANCH
git push origin :NAME_OF_MY_BRANCH

This removes your branch locally and from your project on GitHub. For new changes go back to step 4.)

6.) What if

6.1) You get comments

Make changes to the code in your branch to make the reviewers happy. Then git add your changes and git commit --amend, modify the commit message if needed. Push your branch git push --force origin NAME_OF_MY_BRANCH. The code in the pull request automatically updates and the reviewers can see your changes. You might want to add a comment to the discussion that you updated the pull request as the new push does not trigger a notification.

6.2) The upstream master moves ahead

Well, your changes are wonderful, but the upstream master branch moved ahead because someone else's pull request was accepted first. Follow this sequence of commands to get back in sync:

git checkout master
git pull --rebase upstream master
git push origin master
git checkout NAME_OF_MY_BRANCH
git rebase master
git push --force origin NAME_OF_MY_BRANCH

If there are merge conflicts git will guide you along the way, read the messages from git carefully and make sure you understand them.

6.3) None of the above makes any sense

Read a git book and follow the GitHub tutorials, then read this again