Slide 1

Slide 1 text

Version Control Git & GitHub @kabirbaidhya

Slide 2

Slide 2 text

Version Control

Slide 3

Slide 3 text

What is VCS?

Slide 4

Slide 4 text

Version control systems are a category of software tools that help a software team manage changes to source code over time. https://www.atlassian.com/git/tutorials/what-is-version- control “ “

Slide 5

Slide 5 text

Why Version Control? 1. Collaboration 2. Track complete change history 3. Branching and Merging 4. Versions 5. Revert/Rollback

Slide 6

Slide 6 text

Distributed Version Control Systems Code is hosted in a repository Every client has a complete copy of the repository Synchronize the changes in between client & server Every clone is really a full backup of the repository Example: Git, Mercurial, etc.

Slide 7

Slide 7 text

Distributed Version Control Systems

Slide 8

Slide 8 text

Git

Slide 9

Slide 9 text

What is Git?

Slide 10

Slide 10 text

A Distributed Version Control System (VCS).

Slide 11

Slide 11 text

More precisely, The most popular & widely used modern version control system today.

Slide 12

Slide 12 text

Originally developed by Linus Torvalds the creator of the Linux kernel.

Slide 13

Slide 13 text

What's the big deal about Git?

Slide 14

Slide 14 text

Easy to learn

Slide 15

Slide 15 text

Powerful

Slide 16

Slide 16 text

Performance

Slide 17

Slide 17 text

Flexible

Slide 18

Slide 18 text

Open Source

Slide 19

Slide 19 text

And it's a de facto standard

Slide 20

Slide 20 text

Ge ng Started with Git

Slide 21

Slide 21 text

Installa on Linux Ubuntu/Debain $ sudo apt-get install git Centos/RHEL/Fedora $ sudo yum install git For other distros check the of cial installation docs.

Slide 22

Slide 22 text

Installa on Windows 1. Download the installer from https://git-for-windows.github.io/ 2. Install Git

Slide 23

Slide 23 text

Check Installa on Veriy that git is proplery installed with $ git --version It should print the git version installed on your system like this. git version 2.7.4

Slide 24

Slide 24 text

Configura on

Slide 25

Slide 25 text

Configure git user The rst thing you do after installing git is to set up your user name and email. $ git config --global user.name $ git config --global user.email Then you can check your con g with $ git config --list user.name=Kabir Baidhya [email protected] core.editor=vim core.excludesfile=/home/kabir/.gitignore_global

Slide 26

Slide 26 text

Se ng up a repository

Slide 27

Slide 27 text

Ini alize The git init command creates a new Git repository. # Go to your project directory $ cd /your/project/directory # Initialize a git repository $ git init

Slide 28

Slide 28 text

Clone The git clone command clones a remote repository into the local machine. This will create a complete copy of remotely hosted repository in your local computer. $ git clone [directory]

Slide 29

Slide 29 text

Saving Changes

Slide 30

Slide 30 text

Adding files In order to save your changes to the repository you'll need to commit your changes. You rst need to select les you want to commit using this git add command. # Add specific file(s) $ git add # Add whole path or directory $ git add # Add all of your changes $ git add --all

Slide 31

Slide 31 text

Commi ng changes The git commit command commits the staged changes to the history. $ git commit This will ask you to enter a commit message for your commit. In case you don't like to be prompted for the message, you can set directly using the -m option like this $ git commit -m "This was my first commit"

Slide 32

Slide 32 text

Inspec ng the repository

Slide 33

Slide 33 text

Checking status We use git status command to display the status of the working directory and the staging area. $ git status If you have nothing to be committed or no untracked les then it would just show some message like this $ git status On branch master nothing to commit, working directory clean But if you have some changes to be committed it lists them.

Slide 34

Slide 34 text

History We can use the git log command to display the history of committed changes on the repository. $ git log There are lots of options available for better inspection of history. For instance, $ git log --oneline # Shows each commit on one line $ git log -n $ git log --author="" $ git log ..

Slide 35

Slide 35 text

Working with remote

Slide 36

Slide 36 text

Adding a remote You need to add remote repository urls of a remote server to be able to synhronize your changes with the remote repository. You can do this using the git remote add command. $ git remote add You can verify added remotes by doing $ git remote -v It should list the urls to the remote repositories you've added so far.

Slide 37

Slide 37 text

Pushing your changes Push all the changes (commits) you did to your local repository to the remote repositories is pretty simple with git push command. # Push a local branch changes to remote $ git push # Push all the changes of local branches to remote $ git push --all For instance: $ git push origin master

Slide 38

Slide 38 text

Pulling remote changes The git pull command fetches the changes of the current branch from remote and merges it into the local branch. This is same as running the combination of git fetch and then git merge . $ git pull [branch] Example: $ git pull origin master

Slide 39

Slide 39 text

Checking out code

Slide 40

Slide 40 text

Checking out Checking out code actually means to take your working directory to a speci c change (commit), branch, tag or or even different versions of les. You can do all these things with just a simple command git checkout . $ git checkout # go to that commit $ git checkout # checkout that file to previous $ git checkout # go to another branch $ git checkout # go to a tagged version of the r

Slide 41

Slide 41 text

Branching & Merging

Slide 42

Slide 42 text

Branching The git branch command allows you to list, create and delete branches. To create a new branch you can do $ git branch

Slide 43

Slide 43 text

Merging You can use git merge command to merge changes of a branch into the current HEAD . Merging a branch into your current branch is as simple as: $ git merge

Slide 44

Slide 44 text

GitHub

Slide 45

Slide 45 text

GitHub Software development platform Sort of Social networking platform for developers Provides Git repository hosting services & web based platform to manage repositories and projects Popular for open source projects

Slide 46

Slide 46 text

Read More?

Slide 47

Slide 47 text

Links 1. https://git-scm.com/book/en/v2 2. https://www.atlassian.com/git/tutorials/what-is- version-control 3. https://try.github.io 4. https://www.git-tower.com/blog/git-cheat-sheet/

Slide 48

Slide 48 text

Thank You @kabirbaidhya [email protected] The slides were created using Marp. https://yhatt.github.io/marp/