welcome to git


By

Loganathan B







What is VCS?

History of git


In 2002, the Linux kernel project began using a proprietary DVCS system called BitKeeper.

In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool’s free-of-charge status was revoked.

Advantages


  • Speed
  • Simple design
  • Strong support for non linear development
  • Fully distributed
  • Able to handle large projects.

Git Basics


working concepts

Git Basics continue.

snapshot

Git Installation.

Download
http://git-scm.com/downloads
http://git-scm.com/book/en/Getting-Started-Installing-Git

At first time
   $ git config --global user.name "your name"
   $ git config --global user.email "your email id"
   $ git config --list
   $ git config user.name


Local git

Create

1)     clone from the remote server     (eg: https://github.com/schacon/grit.git)

2) init


$ Git file states

Git log



$ git log 

$ git log -p -2

$ git log --stat

GIT Undo

$ git commit --amend (for small changes)

$ git reset HEAD <fn>(for unstage)

$ git git checkout -- <fn>

commit reset

$ git reset --hard HEAD~2 (go back to two previous commit)
$ git reset --hard 7ea6057 (go to commit which has the SHA1 hash value
7ea6057)

Branch & Merge


Basic commands in branch and merge
$ git branch
$ git branch <branchName>
$ git checkout <branchName>
$ git checkout -b <branchName>
$ git branch -(SMALL D) <branchName>
$ git branch -D <branchName>
$ git branch -v (it will give you last commit on each branch)

Git Merge

$ git merge <branchName>

1)Merge conflict: no-fast forward
2)Fast forward -> when you try to merge one commit with a commit that can be reached by following the first commit's history, git simplifies things by moving the pointer forward.

Git on Remote

Setup your remote

$ ssh userName@server (login)

ssh public key setup

$ cd ~

$ cd .ssh

$ ls -ltar (to check id_dsa, id_dsa.pub, id_rsa, id_rsa.pub)

$ ssh-keygen

append public key content to server's authorized_key file.

Git on Server

$ git clone <URL>

$ git remote (list out remote short name)
$ git remote -v

$ git remote add <remoteName> <remoteURL>
$ git fetch <remoteName>
$ git pull
$ git push

Remote branch

Remote branch

View remote

$ git remote

$ git remote -v

$ git branch

$ git branch -r

fetch

$ git fetch <remote> <branchname>

$ git pull <remote> <branchname>

$ git checkout <remotebranchname>

Remote Branch



Create a remote branch

$ git push origin <localbranch>:<emotebranch>

Delete a remote branch

$ git push origin :<remotebranch>

Inspect a remote


$ git remote show <remoteName>

$ git remote rename <oldname> <newName>

$ git remote rm <remoteName>

GIT Tag

lightweight and annotated tags.


Creating annotated tags(-a & -m)
$ git tag -a v1.4 -m 'my version 1.4' Annotated Tags

$ git tag -a v1.2 -m 'version 1.2' 9fceb02 create a tag at a particular commit if you forget to tag


Tag Continue...

Create lightweight tags(don’t supply the -a, -s, or -m)

$ git tag v1.4-lw


View tags
$ git tag
$ git tag -l 'v1.4.2.*'
$ git show v1.4

Tag Continue...

Sharing tags

$ git push origin v1.5

$ git push origin --tags (This will transfer all of your tags to the remote server that are not already there.)



Reference:

http://git-scm.com/documentation


Thank you.

git basics

By Torry Harris Business Solutions