Set
Shortcut command settings
git config--global alias.st status
git config--global alias.ci "commit-a"
git config--global alias.co checkout
git config--global alias.br branch
git config--global alias.dc dcommit
git config--global alias.rb rebase
Color Interactive Interface
git config--global color.branch auto
git config--global color.diff auto
git config--global color.interactive auto
git config--global color.status auto
git config--global core.autocrlf input
Set up user personal information
git config--global user.name "yyy"
git config--global user.email "yyy@yyy.com"
Develop common operations
Cloning a project to a local
git clone git://your-git-server/your-project.git Your-project
Set up a remote warehouse
# Add (Origin is an indicator and can be changed at will)
Git remote add Origin git://your-git-server/your-project.git
# Delete
Git remote Remove origin
Manipulating remote warehouses
# Commit local Modifications (commit local modifications to the remote Master branch)
Git push Origin Master
# Merge Remote modifications (merge the remote Master branch in)
Git pull Origin Master
# Remove branches from remote repositories
Git push:branch
Basic operations
# Commit Changes
Git add/path/to/file
git commit-m reason
# Submit All Changes
Git commit-a-M reason
# Create local Branches
Git Co-b branch_name
# View Branches
Git branch
# Delete Branches
Git branch-d branch_name
# View the differences between branches
git diff Master Branch
# See the difference between the latest version and the previous version (one ^ indicates a version to move forward)
git diff HEAD head^
# View Status
git status
# Merging Branches
Git pull. Branch
# Destroy your own changes
git reset--hard
You can also interact with SVN
# Cloning from the Subversion repository
Git svn clone https://googlecode.com/svn
# commit local modifications to Subversion repository
Git svn dcommit
# Import a new Subversion update
Git svn rebase
Collaborative work Flow
1. After the local modification of the confirmation, you need to submit to the main library, using
git push
If the remote commit fails, the failure information such as:
To Git@www.ee.com:che.git
! [Rejected] master, master (Non-fast forward)
Error:failed to push some refs to ' git@www.ee.com:che.git '
At this point you may be prompted for file conflicts under the main library,
2. You need to perform
Git pull
Synchronize the latest version of the main library to local, if prompted as:
Remote:counting Objects:5, done.
Remote:compressing objects:100% (2/2), done.
Remote:total 3 (Delta 0), reused 0 (Delta 0)
Unpacking objects:100% (3/3), done.
From Git@www.yxx-inc.com:che
0c94dbe. 52A81FE Master--Origin/master
Auto-merged Readme
CONFLICT (content): Merge CONFLICT in Readme
Automatic merge failed; Fix conflicts and then commits the result.
This is a hint that you have a file Readme conflict with the main library and you will need to handle the conflict manually later.
3. File conflicts, Git prompts you in the following way
<<<<<<< Head:readme
Test by Wangbai and Yancan and someone haha
=======
Test by Wangbai and Yancan and somthing
>>>>>>> 52a81fe3acf426bbae164a00ba3413550e056672:readme
4. After manually resolving the conflict, you need to re-commit and push
Git commit
git push
As shown:
Counting Objects:10, done.
Compressing objects:100% (5/5), done.
Writing objects:100% (6/6), 639 bytes, done.
Total 6 (Delta 0), reused 2 (Delta 0)
To Git@www.xx-inc.com:che.git
52a81fe. bb31966 Master, Master
Submit Success
Quick Start Tutorials:
Click to open link