"I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'. "
Linus Torvalds
~ $ git init blog Initialized empty Git repository in /home/kalmario/blog/.git/
~/blog $ ls -la
total 12K
drwxrwxr-x 3 kalmario kalmario 4.0K 2013-10-26 12:45 ./
drwxr-xr-x 49 kalmario kalmario 4.0K 2013-10-26 11:40 ../
drwxrwxr-x 8 kalmario kalmario 4.0K 2013-10-26 11:40 .git/
~ $ git clone https://github.com/larkarvin/TestRepo.git blog
Cloning into blog...
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 16 (delta 3), reused 16 (delta 3)
Unpacking objects: 100% (16/16), done.
~/blog $ git config --global user.name "larkarvin" ~/blog $ git config --global user.email "arvin@almar.io"
~/blog $ git config --global -l user.name=larkarvin user.email=arvin@almar.io
~/blog $ git config -l
user.name=larkarvin
user.email=arvin@almar.io
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/larkarvin/TestRepo.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
~/blog $ vim home.php ~/blog $ git status
# On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # home.php nothing added to commit but untracked files present (use "git add" to track)
~/blog $ git add home.php
~/blog $ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: home.php
#
~/blog $ git commit -m "First Commit"
[master (root-commit) f40d943] First Commit
~/blog $ git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: home.php
#
no changes added to commit (use "git add" and/or "git commit -a")
~/blog $ git stage home.php
~/blog $ git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# modified: home.php
~/blog $ git commit -m "Commit Message"
~/blog $ git reset home.php
Unstaged changes after reset:
M home.php
~/blog $ git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: home.php
#
no changes added to commit (use "git add" and/or "git commit -a")
~/blog $ git remote add origin https://github.com/larkarvin/TestRepo.git
~/blog $ git push -u origin master
Username:
Password:
Counting objects: 6, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 507 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/larkarvin/TestRepo.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
~/blog $ git pull
Password:
remote: Counting objects: 2, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 41 (delta 27), reused 0 (delta 0)
Unpacking objects: 100% (41/41), done.
From https://github.com/larkarvin/TestRepo.git
1ad00c7..320bd11 master -> origin/master
Updating 1ad00c7..320bd11
Fast-forward
home.php | 8 ++
1 files changed, 20 insertions(+), 13 deletions(-)
~/blog $ git push
Username:
Password:
Counting objects: 12, done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (10/10), 807 bytes, done.
Total 10 (delta 3), reused 0 (delta 0)
To https://github.com/larkarvin/TestRepo.git
6502f62..b8fd39d master -> master
~/blog $ git diff home.php
diff --git a/home.php b/home.php
index 70c74b9..cf67afb 100644
--- a/home.php
+++ b/home.php
@@ -1,4 +1,4 @@
- <title> Hello World! </title>
+ <title> Hello Universe! </title>
~/blog $ git branch -l
* master
~/blog $ git branch develop
~/blog $ git branch -l
develop
* master
~/blog $ git checkout develop
Switched to branch 'develop'
~/blog $ git branch -l
* develop
master
~/blog $ git checkout develop
Switched to branch 'develop'
~/blog $ vim home.php
~/blog $ git stage home.php
~/blog $ git commit -m "Commit Message"
~/blog $ git checkout master
Switched to branch 'master'
~/blog $ git merge develop
Merge made by recursive.
home.php | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
~/blog $ git mv home.php index.php
~/blog $ mv home.php index.php
~/blog $ git rm home.php
~/blog $ git add index.php
~/blog $ git log
commit b8fd39d4ca134662d44c1a90c2d95c16ff97f183
Author: larkarvin
Date: Sat Oct 26 13:45:31 2013 +0800
Change Title
commit 98fed4c365e56309569cb03402e60a263b992350
Merge: a3e8b02 abf9968
Author: larkarvin
Date: Sat Oct 26 10:55:48 2013 +0800
Merge branch 'develop'
~/blog $ git checkout home.php
~/blog $ git diff home.php
~/blog $ cat .gitignore
*.jpg
*.png
/includes/local-config.php
~/blog $ git tag v3.0
~/blog $ git tag -l 'v1.1.*'
v1.1.2 v1.1.3 v1.1.4
https://slid.es/larkarvin/git-basics/
http://almar.io
@larkarvin
Karl Arvin Almario
October 26, 2013
Solutions Architect at US AUTOPARTS NETWORK