Tutorial 0 Introduction - McGill-ECSE429-Winter2022/tutorials GitHub Wiki
Use this tutorial to get started with Git! Credits to: Marton Bur
Install the Git version control system (VCS) from https://git-scm.com/downloads.
-
Create an account on https://github.com/.
-
Verify your e-mail, then log in using your credentials.
-
Visit https://github.com/ then click on New repository (green buttom on the right).
-
Set your user as the owner of the repository.
-
Give a name for the repository (e.g., ecse429-tutorial-1), leave it public, then check Initialize this repository with a README. Click on Create repository afterwards. At this point the remote repository is ready to use.

-
Open up a terminal (Git bash on Windows).
-
Navigate to the designated target directory (it is typical to use the
gitfolder within the home directory for storing Git repositories, e.g.,cd /home/username/git). -
Using a Git client, clone this repository to your local Git repository. First, get the repository URL (use HTTPS for now).

Then, issuegit clone https://url/of/the/repository.git
You should get an output similar to this:

-
Verify the contents of the working copy of the repository by
ls -la ./repo-name. The .git folder holds version information and history for the repository.
-
Open up a terminal and configure username and email address. These are needed to identify the author of the different changes.

Glossary — Part 1:-
Git is your version control software
-
GitHub hosts your repositories
-
A repository is a collection of files and their history
-
A commit is a saved state of the repository
-
-
Enter the working directory, then check the history by issuing
git log. Example output:

-
Adding and commiting a file: use the
git addandgit commitcommands.

The effect of these commands are explained on the figure below:

Glossary — Part 2:-
Working Directory: files being worked on right now
-
Staging area: files ready to be committed
-
Repository: A collection of commits
-
-
Checking current status is done with
git status.

-
Staging and unstaging files: use
git resetto remove files from the staging area.

Important: only staged files will be commited.

-
To display detailed changes in unstaged files use
git diff, while usegit diff --stagedto show changes within files staged for commit.

-
Reverting to a previous version is done using
git checkout.

-
The commands
git pull(or thegit fetch+git rebasecombination) andgit pushare used to synchronize local and remote repositories.

-
You can browse pushed commits in the remote repository online using GitHub. You can select the commits menu for a repository.

To get a link for a specific commit, click on the button with the first few characters of the hash of the commit.

-
cd: change/navigate directory -
ls: list contents of a directory -
ls -la: list all contents of a directory in long listing format -
touch: create a file -
cp: copy a file -
mv: move a file -
rm: remove a file -
mkdir: create a directory -
cp -r: copy a directory recursively with its contents -
rmdir: remove a directory -
rm -rf: force to recursively delete a directory (or file) and all its contents -
cat: concatenate and print contents of files -
nano: an easy-to-use text editor
The source for most of the images in the Git documentation: https://github.com/shabbir-hussain/ecse321tutorials/blob/master/01-githubTutorial1.pptx