Read other entries of our GitHub Daily Guide.
One interesting thing to realise about GitHub is that it is not a Dropbox like server; this means that changes in your computer are not directly reflected in the online server. You should intentionally upload the current state of your local working folder to the project’s repository on GitHub. Uploading to the repository is called pushing. This might seem obvious for native English but believe me it is not that obvious for others :-P
GitHub is a version control platform, so each time you push your changes to the repository they are archived and linked to a commit code. Each commit is identified by a unique code.
So, what is the rationale and steps to correctly push your changes to the project’s repository?
- It is important to know is that you do NOT need to push all your files or all your changes (modified files) in the same commit/push step. You can select each of the files you want to upload.
- To produce a push operation, firstly you should confirm which files have been hanged. You can ask git to show you the status of your project’s folder with the status command.
This shows you which files have been changed and which files are new and need to be tracked by git (if you want obviously).
- select the files you want to push into the server using the git add command.
git add <file>
there are additional commands that you can do to simultaneously select multiple files, this is called wildcards (gogo google it;-)).
- once the files have been selected you must commit them. You can think of it as organising everything in a archive under a message, the commit message. You can write short or long messages. These messages should be highly descriptive of the changes you are committing. It is important that each commit focus only on a single idea: some improvement, solving an issue, formatting, whatever.
git commit -m "YOUR MESSAGE"
or if you want to write a more detailed description,
this will open your preferred text editor. The first line will be formatted as a title and the text that follows is the commit message. Save and close the file.
- Now you need to actually push the changes, that is, committed files, to the repository. When working on the master branch simply use the push command.
And that’s it. The changes you have pushed are now on the online repository. Next time someone clones or pulls from your project, those changes/modifications/updates will be there.
There are many many many more details about this operation. Nevertheless, this post covers the most basic procedures and ideas that you should retain and get familiar with to start developing your own project on a daily basis using the GitHub version control platform.
As far as our knowledge goes, to start working on a project on GitHub you should first create that project from scratch on your profile, fork an interesting project to your account or directly clone to a local folder someone else’s project. Whatever the situation is, the key step is to clone the repository to your local computer, where actually the work will take place.
When I first started on GitHub, a big doubt was about what actually meant the word cloning. Well, it’s very simple: it means copy the project repository, that is, the whole project itself, to a folder on the local computer. Going a bit more technical, it means to copy the master branch together with information on all branches associated to that project – so that you can change between branches.
An interesting thing of cloning is that it can be done as many times as possible. You can actually think about the repository as an online backup. Many times, when things in my project’s folder simply get too messy, and I have nothing to loose or backups to care about, it is easier for me to simple delete the project’s folder and clone it again from scratch that trying to checkout the previous commits or maneuvers alike. Also if you find yourself in a different computer, simply cloning your repository and up are up to go. Sometimes, if you are continuing your work in a computer which you have not used for a long time and the project there is way behind the current version, it is easier to delete the old folder and clone again from the server than trying to update an old version.
Cloning a GitHub repository to your computer
You have created a project in your Git account and you want to clone it to your computer so that you can work on it. Or you have forked a project, or just want to clone somebody else’s open project…
Simply, go to the parent folder where you wish to store the project files and do:
git clone <url>
where <url> is the project url :-) for example:
git clone https://github.com/joaomcteixeira/hello-world
This creates the subfolder hello-world in the location where you typed the above clone command. If you want to clone a repository to a specific folder, just add the folder name after the url.
git clone <url> <folder>
I guess that with each personality comes different tastes (or the other way around). Regarding coding, each one of us has his/hers preferred colour scheme. If you don’t have yours is because you haven’t searched enough :-)
For Geany there are a bunch of pre made schemes which are quite nice.
I really don’t know about others… but, maybe because I am synesthetes I constantly feel the need to change colour scheme each time I change ideas about a project, or start a new development, or learning something new and big.
This time isn’t different, I found myself comfortable with the Vibrant theme on Geany =)
Actually so comfortable that I want to write it here, just in case for the future :-P
a little screenshot of piece of work I use that was taken from external web site (see docstring ;-)
Find the colour scheme by Jason Wilson here =)