Git & Github Fundamental


About Me !

What is git

Manage your source code versions

Who should use Git

  • Anyone wanting to track edits
  • - Review a history log of changes made

    - View differences between versions

    - Retire old versions

  • Anyone needing to share changes with collaborators
  • Anyone not afraid of command line tools

Git is Popular

  • Distributed Version Control
  • Open source and free software
  • Compatible with Unix-like Systems (Linux, Mac OSX, and Solaris) and Windows
  • Faster than other SCMs (100x in some cases)

Distributed version Control

  • No Need to communicate with a central server
  • => Faster

    => No network access required

    => No single failure point

    => Encourages participation and "forking" of projects

    => Developers can work independently

    => Submit change sets for inclusion or rejection


Centralized Vs Distributed

No network Needed

  • Performing a diff
  • Viewing file history
  • Commiting Changes
  • Merging branches
  • Obtaining other revision of file
  • Switching branches

Get a Virtual Machine



=> git --version

=> which git (linux)

Git Basic Workflow

(working with local git repo)

    -- git init
    • It create a git empty repo. Also creates a .git in the current dir
    -- git add
    • Adds all files (except .git)
    -- git commit
    • Commits the changes (in this case initial commit)
    • Creates a branch named master
    • HEAD points at master

Git workflow

Create a git repo

  • git init

Configuring Git ...

  • git config --global "rajesh kumar"
  • git config --global
  • git config --list

Create some files/code

  • Linux
  • -- touch filename

    -- vi filename

    -- cat > filename

    -- echo "some text" >> filename

Add file to git repo

- git add <filename>

Commit to git repo

> git commit -m"This is my First commit"

Check the list of commit

> git log

Check the status of current repo

> git status

Working with remote repo


Git Basic Workflow

(working with remote git repo)

Sign up

Create a new repos in github

Add remote depot to config

git remote add origin

Push to Remote repo

> git push -u origin master

github to local git workflow

  • Working with Remote Repos
  • - git clone
    • Creates a git repo from an existing repo
    • All remote branches are tracked
    • Remote HEAD branch checked out as your initial master branch as well
    - git add
    • Adds all files (except .git)
    - git commit
    • Commits the changes (in this case initial commit)
    • Creates a branch named master
    • HEAD points at master
    - git push


Linux Linux Git
pwd - Current Directory mkdir git-training - Create a directory called git-training git init
ls - Listing the directory ls - Listing the directory git --version - To know the version of git.
which git - where the git is installed history - Display the list of all run commands git status - To know the status of my current git repo
sudo apt-get install git - To install a git in Ubantu cd - Change directory. git add .Or git add
clear - Clear the screen ls -la - To List files n directory including hidden git commit -m"This is my message"
touch ashok.txt - To create a file git log
vi harikiran.txt - To create a file
cat > rajesh.txt - To create

scmGalaxy Community


Thanks !!!