git 程式碼版本控制軟體介紹
TRANSCRIPT
git
Introduction to git
Author: Holan LiaoEmail: pinglunliao at gmail dot com
Pro Git
Agenda
What is Git
Git Commands
Labs(optional)
What is Git.
Distributed Version Control Systems (DVCSs)
Local
Other Version Control System way
The git way
Snapshots!
The git Local Operations
Git Commit
Single commit repository data
SHA1hash:98ca9..0de24..e8455..Etc.
Git object data for multiple commits
Repository(Before committing)
Repository
mkdir newRepositoryName
cd newRepositoryName
git init (.git)
Initial Commit
README
vi README
git add README
git commit -m 'Initial commit'
Initial Commit
Git
Git
git add . # staging area, add , commit .
git add filename
git add modify-file # , add. ( commit -a )
git add -u # , .
git add -i #
Git
git rm filename
Git
git commit
git commit -m 'commit message'
git commit -a -m 'commit -message' # commit, add.
git commit -a -v # -v , -a commit
Commit
//
bug fixed
unit test commit
commit
commit
git diff --check
commit
Commit
Commit/Patch
git diff --check
Commit
git add --patch
Stage
Commit Message
.gitignore ( commit )
~/.gitignore ( Global )
.gitignore
https://github.com/github/gitignore
git log (console)
GUI
gitk --all
giggle (http://live.gnome.org/giggle)
git log --pretty=oneline --max-count=2
git log --pretty=oneline --since='5 minutes ago'
git log --pretty=oneline --until='5 minutes ago'
git log --pretty=oneline --author=
git log --pretty=oneline --all
git log --all --pretty=format:"%h %cd %s (%an)" --since='7 days ago
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
Git
...!?
Commit
git commit amend
Stage Unstage
git reset HEAD file
git checkout -- file
committed
git ls-files -d #
git ls-files -d | xargs git checkout -- #
git revert HEAD # commit
git reset HEAD filename # staging area unstaging untracked ()
git checkout filename # unstaging Repository ()
reset ( commit )
git reset e37c75787
git reset HEAD^ ( working tree)
git reset HEAD^ --soft ( staging area)
git reset HEAD^ --hard ()
revert ( commit )
reset revert commit
git revert e37c75787
git revert HEAD^
Git Branch
Branch pointing into the commit datas history
Multiple branches pointing into the commits data history
HEAD file pointing to the branch youre on
HEAD points to another branch when you switch branches
The branch that HEAD points to moves forward with each commit
HEAD moves to another branch on a checkout
The branch histories have diverged
(Branch)
C: commit master
(master) git branch iss53
git checkout -b iss53
git branch iss53 ()git checkout iss53 ()
(iss53) git commit
(master) git branch hotfix
(hotfix) git commit
(master) git merge hotfix
Fast forward merge
(master) git merge iss53
The best common-ancestor
After merged
Git automatically creates a new commit object (C6) that contains the merged work.
Merge v.s. Rebase
Merge
Rebase
Merge v.s. Rebase
Rebase
rebase ( local branch)
1. branch
2. branch commits
apply/patch
commit log local branch
Note!!!
push commitspush !!
Git
git branch [branch_name]
git branch hello (hello)
git branch -d [branch_name]
git branch -d hello (hello)
Git
(*)
git branch
git merge [branch_name]
git merge hello
Git rebase
rebase
git rebase [branch_name]
git rebase hello
Git Remote
git remote add [shortname] [url] # Repository branch(origin -> project)
git branch -r # Repository branch
git remote rm [shortname] #
git remote rename [shortname] [newName] #
git remote update # Repository branch
git remote # Remote shortname
git remote -v # Remote shortname & URL
Git Push () & Pull ()
git push [remote-name] [branch-name]
git push origin master
git pull [remote-name] [branch-name]
git pull origin master
push
commits
commit
commit commits
commits
http://nvie.com/posts/a-successful-git-branching-model/
Workflow
Git Tag
Listing tag
git tag
Creating annotated Tag
git tag -a R1.4 -m 'my version 1.4'
git tag -a -m ''
git show R1.4
Git Tag
Sharing Tags
git push origin master [tag-name]
git push origin master --tags
git push origin master R1.4
Sync your code
git pull [URL] [BRANCH_NAME]
git pull origin master
git pull origin master --tags
git push origin master --tags
Some suggestions
PushPush Pull
tag
TagRRelease
TagDDevelopment
etc.
localBranchPushmaster
KISS (Keep It Simple & Stupid)
Q & A
Discussion
Git Lab
(http://gitimmersion.com/)
Git
gitInit.sh
./gitInit.sh userName userEmail
./gitInit.sh pinglun [email protected]
Install
git
sudo apt-get install git-core git-gui
SSH Key
ssh-keygen -t rsa
Setup
User Configuration
git config --global user.name "Ping-Lun
git config --global user.email "[email protected]"
Editor
git config --global core.editor gedit ( vim or vi )
Setup
Line Ending Preferences
git config --global core.autocrlf input
git config --global core.safecrlf true
Color Highlighting
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
Commit & Status
lab1.sh
Branch & merge
lab2.shscripttmptmpdevel, feature, master, releasebranchesbranch merge
Git http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/
-- GIT http://www.javaworld.com.tw/jute/post/view?bid=33&id=282726&sty=3