Written by Raviteja Lingineni
So you want to learn git eh, well it’s easy!
Here are a couple reasons why you might want to learn how to use git and Github:
Code is always changing, sometimes those changes break the code. Git can help you revert changes and see what you changed.
People work on big projects together, and independently. Use Github to make pull requests and change code and work on your own branch to keep things from breaking.
Open Source is the way to go! You can publish your code, open issues and make pull requests that could help projects! In addition, you can also manage a project using Github.
In this workshop here is what we will be doing:
Get the Github Desktop Client
You can get started by installing the Github Desktop Client
You can also use git from the command-line, but this is much easier for beginners. It’s easier to visualize as well
Make a Github Account
As the client installs, if you don’t have a Github Account, make one now. You can do it by going to the Github Website.
Set up the Github Desktop
Configure things like where repositories will go once they are saved and login to Github in the client.
Explore Github
Play around with the actual Github website. Checkout what it is. Take a look at the Enlight Github. Every project or repo contains code of some sort. Code for the current Enlight Website can be seen there.
Modify the file locally
Go to the names folder, and create a new file using a text editor of your choice. Call it <yourname>.js
Make this file hold the following:
function main() {
console.log("I'm about to commit a change");
}
main()
Go back to the Github Client. You should see that your changes to the git Repo are reflected. Git watches your projects and looks for changes. Using the client, write a simple commit message on the bottom. All commits need messages
After we make our changes, we want to be able to push the code to the original master that is sitting on Github. Don’t you want to share your code?
First of all, modify your changed file to say:
function main() {
console.log("<put your name here> just sent a pull request!");
}
main()
Head back to the client. Commit your change earlier and put in a commit message. Make it detailed, say your name, and what your change was.
Now in the top right corner, above the sync
button, you will find the Pull Request Button. Write a message, and piush your pull request! It should be visible in Github under the pull requests tab!
That’s all it takes to collaborate code on Github and track changes to your code. You can also manage a project and assign people to solve different issues. Hopefully, you get a feel for git with this, and we are hoping that your larger projects can make use of Git.
Note
You don’t always have to make pull requests. Sometimes, you might trust the people to commit. You can have people just commit code, and hit the Sync
button to push changes by adding collaborators.