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.