I’m going to be honest. I … hate … git.
Figuring out how to use git to push my changes up for 0.2 took longer than it did to write all my 0.2 code and all the tests and demos that went along with each function (over 1000 lines of code for all the tests and demos).
So to make sure I never have to go through this hell on earth again I’m writing a post to remind myself how to do it later and to help out anyone else who has trouble with git.
This is a ‘git for dummies’ tutorial strictly laid out for the people working on processing.js and the commands are all tailored to what we have to do from start to finish. From cloning the repo locally to making changes, committing, checking status, and then pushing the changes to your fork.
This will include only the bare essentials to just do it and avoid any of the other crap you just don’t need to know and that will confuse you (and me later when I reread this to do my next releases). A more detailed tutorial for the basics is here.
This tutorial assumes you already have git installed and configured to connect properly. If you do not have that then read an excellent post by Anna from my DPS909 course on how to setup git for the processing project here.
- Create a fork of the latest code.
- Clone the repository to copy the latest code to your computer. OR pull the latest updates if you have already cloned before.
- Make the changes to the code with your new content.
- Mark your changed files by committing them and add a comment about the changes you made.
- Push your new code up to your fork.
- Request a pull of your new code from F1LT3R Post in your lighthouse ticket the branch and commit links for your changes to get your new patch reviewed.
That’s it. Here are the details
1. Create a fork of the latest code. If you already have an old fork and need to delete it just click the edit button and all the way at the bottom you’ll see a delete option. git wouldn’t let me have 2 forks going at the same time. Or its a bug that when you click fork on the newest code it doesn’t let you and takes you to your old fork I don’t really know why or care anymore at this point.
From the picture below go to this address and select the fork button. Give it about 20 seconds and refresh the page and it will be your new fork.
2. Clone the repository to copy the latest code to your computer. OR pull the latest updates if you have already cloned before. I did a fresh clone in a new directory to make it simple.
3. Make the changes to the code with your new content. Change whatever you need to in the code.
4. Mark your changed files by committing them and add a comment about the changes you made. After making changes to your files you have to commit which files you want to prepare to be pushed up to the repository.
This picture explains the process well.
To commit use the command ‘git commit -a’ for all changed files. Or use ‘git commit <filename>’ for one specific file at a time. Using commit only queues the file up to be pushed soon, it doesn’t send the file to the repository right away. Add the attribute -m on the end of the command to specify a comment for the commit when it gets pushed to git hub later.
Look at this picture for how I did it
5. Push your new code up to your fork. Now that your code is marked as committed and ready to be pushed you just have to push it. First you can check the status of what is ready to be pushed with >git status.
It says no changes added to commit but its wrong don’t worry about that the important part is it says ‘your branch is ahead of origin/master by 1 commit’. Now your ready to push.
Type >git push firstname.lastname@example.org:<username>/processing-js.git
Assuming your fork is called processing-js.git just substitute <username> for your username. Just check your fork location in the repository for what to put here. It’s not jeresig/processing-js.git.
You can also create alias names for your url to your fork. using >git remote add <aliasname> git://github.com/<username>/processing-js.git . you will want to add at least an alias for these two remotes shown below as well for pulling code later. these alias names just allow you to type shortcuts and are easier to remember for repo names. IE: >git pull dhodgin branchname
git remote add annasob git://github.com/annasob/processing-js.git
git remote add dhodgin git://github.com/dhodgin/processing-js.git
6. Post in your lighthouse ticket what you did, the link to and name of the branch you have your changes in, and the link to the commit of the patch. Your ticket will be peer reviewed and then super reviewed before finally being pushed into the next release code base.Request a pull of your new code from F1LT3R. Go to your fork on the website and click the ‘pull request’ button. From the popup select F1LT3R from the list of people and click ‘Send pull request’ at the bottom.
You can check if everything worked OK by looking at the network graph.
Hopefully it worked for you. If it didn’t … then may your god have mercy on your soul.