GITHUB BASICS
This guide teaches you step-by-step how to get started with github, or other flavors of git (using the command line).
Installation
Mac OS:
- Open terminal.
-
$
git --version
If you see output like:
git version 2.20.1 (Apple Git-117)
; Git is installed.Otherwise you will be prompted to install xcode tools. Please follow steps to install these.
Linux
In console
$ sudo apt install git
.
Windows
Download Installer
https://git-scm.com/download/win
Please install git-bash as well. We will assume you are using git-bash to follow along with this tutorial on Windows.
Motivation
Why use Git? If you are interested in doing any/all of the following
- Use GIT for maintaining your code/design project files.
- Collaborate with teammates over the cloud (think Google docs but for project files).
-
Better than backups: https://git-scm.com/book/en/v1/Getting-Started-Git-Basics
- Publish/access open source code.
Lifecycle
The git lifecycle includes creating versions (“commits”) of your development folder as and when it changes. You will
“add” files to be “tracked” in your folder by the git add
command. You stage the added files for a “commit” (version) by using the git commit
. If your repository is maintained on the cloud, you will need git push
to sync the new version created with your cloud (remote) repository.
You can create a remote repository by hosting your own git server, or use Git-as-a-Service(GaaS) providewrs like GitHub, GitLab, Bitbucket etc. The following tutorial uses Github as GaaS, but the commain-line steps should work the same with any GaaS.
Tutorial
- Create a Github account
-
Create a Github Repo
-
Find repo url
-
Clone repo $
git clone <yout repo-url>
This will create a folder with the repo name and “checkout” the lastest commit. -
cd to new folder created, you can now add/edit delete/files from thgis folder.
-
To create new commit $
git add *
$git commit -m "<your-message>"
- To sync your repo with cloud repo
$
git push