Git 1 Notes - 294357
Git 1 Notes - 294357
Git 1 Notes - 294357
Introduction:
Ever felt frustrated because of not being able to recover a small code snippet
which got deleted accidentally? If the answer to the above questions is yes,
then this tutorial is for you.
This tutorial assumes that you already have a GitHub account and the Git
Bash application installed on your system If not follow step 1 or watch lecture
video.
Defining Keywords
Before learning to use GitHub, let’s understand some common terminologies which
you will encounter throughout this tutorial:
Stage & Commit — Creation of a new project version, on your git repository, is
a 2 step process. The first step is to collect all the files which are required to be a
part of the new version. This is called staging the files. The second step is to
create the new version of your project which is called committing. Only those
files which are staged, can be committed to a new version.
Push & Pull — Given our focus on GitHub, push and pull is about interacting
with repositories stored on GitHub’s cloud. A pull is like downloading the latest
version and a push is synonymous to uploading your latest version on GitHub
Once you are more comfortable with the command line, you can download Git
software with a user interface.
For Ubuntu:
First, update your packages:
$ sudo apt update
Next, install Git with apt-get:
$ sudo apt-get install git
$ git --version
For MacOSX:
First, download the latest Git for Mac installer.
Next, follow instructions on your screen.
$ git --version
For Windows:
First, download the latest Git for Windows installer.
Next, follow instructions on your screen (you can leave the default options).
Finally, open a terminal (example: powershell or git bash) and verify that Git is
installed correctly:
$ git --version
This should be done only once and not for every project, since you are setting
this up globally.
Now get a copy of the repository on your computer. To do that, you need to
“clone” the repository. On the repository page, you need to get the “HTTPS”
address.
$ cd [NAME OF REPOSITORY]
Now you can add all of your files to the staging area using command
git add .
Once you’ve added and committed all your files, run this command to push all
your commits to your repo.