Sunday, February 23, 2014

git -- simple tutorial

Git /ɡɪt/ is a distributed revision control and source code management (SCM) system with an emphasis on speed.[4] Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005.
Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.
Git is free software distributed under the terms of the GNU General Public License version 2.

1-  init git directory
git config --global "gituser"
git config --global ""

mkdir dir1
cd dir1
git init

2-  add file to git repository
echo "first" > readme.txt
git add readme.txt
git commit -m "first commit"

3- modify and commit

echo "second line"  >> readme.txt
git commit -a -m "update the readme.txt file"

4- add remote git and sync
git remote add origin
git push -u origin master

5- show commit history
git log

commit 02830e68d948bf85cc060155a8698f68b17c6130
Author: theamdara <>
Date:   Sun Feb 23 15:15:20 2014 +0700

    update with print stat

commit 5939fd9d7350f39b398f643e49ae8e0b062ebd68
Author: theamdara <>
Date:   Sun Feb 23 15:07:00 2014 +0700


commit 7fc32d4b349a6cf04710120425c74e6f1b057e57
Author: theamdara <>
Date:   Sun Feb 23 14:58:40 2014 +0700


commit de5f0e4b5c78de82f1175282b665fbf7c70bb8cb
Author: theamdara <>
Date:   Sun Feb 23 14:55:30 2014 +0700


6- checkout git commit older or new version
 - checkout for latest version
 git checkout HEAD .
 - checkout for older version git checkout <commit-hash> <filename>
 git checkout de5f0e4b5c78de82f1175282b665fbf7c70bb8cb

No comments:

Post a Comment