Configure Git for the first time
git config --global user.name "txn"
git config --global user.email "txn@qq.com"
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.last 'log -1 HEAD'
Working with your repository
git clone http://txn@10.15.3.9:7990/txn.git
My code is ready to be pushed
cd existing-project
git init
git add --all
git commit -m "Initial Commit"
git remote add origin http://txn@10.15.3.9:7990/txn.git
git push -u origin master
My code is already tracked by Git
cd existing-project
git remote set-url origin http://txn@10.15.3.9:7990/txn.git
git push -u origin master
Common Commands
git add .
git commit -m "Update"
git commit -a -m "Update"
git pull origin master
git push origin master
git pull(git fetch,git merge)
git branch -b(git branch,git checkout)
git log --oneline
Branch Workflow
git checkout -b future-plans
git branch future-plans
git checkout future-plans
git checkout master
git merge future-plans
git branch -d future-plans
git push origin future-plans
git push origin :future-plans
Atlassian Git Tutorial
Learn Git with Bitbucket Cloud
git clone https://emmap1@bitbucket.org/emmap1/bitbucketstationlocations.git
git status
git add locations.txt
git commit -m 'Initial commit'
git push origin master
git pull --all
git branch -b future-plans
git branch future-plans
git checkout future-plans
git checkout master
git merge future-plans
Learn about code review in Bitbucket Cloud
Learn Branching with Bitbucket Cloud
git branch test-1
git checkout test-1
git push origin test-1
git branch -d test-1
git fetch && git checkout test-2
git merge master test-2
Comparing Workflows
Centralized Workflow
Git Feature Branch Workflow
git checkout master
git fetch origin
git reset --hard origin/master
git checkout -b new-feature
git status
git add <some-file>
git commit
git push -u origin new-feature
git push
git checkout master
git pull
git pull origin marys-feature
git push
Gitflow Workflow
git checkout -b develop
git checkout -b release/0.1.0
git checkout develop
git checkout -b feature_branch
# a bunch of work is done on the features
git checkout release/0.1.0
git merge feature_branch
# assuming that the release branch is done with that feature
git checkout develop
git merge release/0.1.0
git checkout master
git merge release/0.1.0
git branch -D release/0.1.0
git checkout master
git checkout -b hotfix_branch
# work is done commits are added to the hotfix_branch
git checkout develop
git merge hotfix_branch
git checkout master
git merge hotfix_branch
Forking Workflow
相关参考
https://git-scm.com/docs/
https://www.atlassian.com/git
http://git.oschina.net/progit/