Ruby Specialisation: Siddhant Pyasi June 3, 2017
Ruby Specialisation: Siddhant Pyasi June 3, 2017
Siddhant Pyasi
June 3, 2017
i
Contents
1 Git 1
1.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Initialising a Repository . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Create a new repository . . . . . . . . . . . . . . . . . . . 3
1.2.2 Clone an existing repository . . . . . . . . . . . . . . . . . 3
1.3 Working on a repository . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.3 Di . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.4 Commit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.5 Reverting changes . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Remote Repositories . . . . . . . . . . . . . . . . . . . . . . . . . 4
ii
1 Git
Git is a Version Control System (VCS), that keeps track of changes made to files.
There are two main kinds of VCS:
Centralised Examples are the Concurrent Versions System (CVS) and Subver-
sion.
1
Here are a few resources/references for Git:
1.1 Setup
To set up properties globally, use the following commands:
$git config --global user.name El Sid Campeador
$git config --global user.email [email protected]
2. Clone a repository
2
1.2.1 Create a new repository
$cd workingDirectory
$git init
$git add .
$git commit -m Initial commit
1.3.2 Add
This adds:
1. untracked files to be tracked
2. modified tracked file to the staging area
$git add <file/dir>
1.3.3 Diff
There are three kinds of commands here, as shown below.
The first one shows the dierence between staging and working directory:
$git diff
The second one show the changes between HEAD (which is the latest commit
on the current branch) and the staging directory:
$git diff --staged
This one shows the deltas/changes between HEAD and the working directory:
$git diff HEAD
3
1.3.4 Commit
This commits your changes to the repo:
$git commit -m Your message here
1. Before Committing
$git checkout . (This is to reverse the status of all files overwriting
local changes)
$git checkout -- <file> (This is to reverse just one file)
2. After Committing
$git revert HEAD (Reverts the most recent commit)
The default alias for a cloned repo is origin. To push changes to your branch
out:
$git push alias branch_name