First, upgrade install git
Use terminal upgrading instruction: git clone https://github.com/git/git
Two, SSH-Keys ready
Using terminal generates a file .ssh
1. determine whether the computer .ssh file already exists
Since .ssh folder default path ~ / .ssh, it is directly determined whether the presence of the folder path
cd ~ / .ssh // when the results do not exist: No such file or directory
mkdir ~ / .ssh // root directory create a folder .ssh
cd ~ / .ssh // into the root directory
Three, git ready
Creating SSH-Keys
Here key above is used to create content .ssh / id_rsa.pub's, title may be named
cd ~/.ssh
open id_rsa.pub //or vim id_rsa.pub
Fourth, generate remote repository
Fifth, use the terminal to complete the operation git
1. upload data from the local side to the remote warehouse
cd /.../ specified path / designated project root directory to locate the data folder //
git init // local library initialization git
git remote add origin [SSH address] // set a remote repository
git add. // add changes to the local library
git commit -m 'commit description' // commit changes to the local library and accompanying description, -m represents a staging area / -am representatives had followed the file, you can submit them to each other at the same time, git commit -m -am 'commit description'
git push -u origin master // push to a remote repository master, you need to enter the password you created when you create a .ssh
2. pull data from a remote repository
cd /.../ for caching file folder to be positioned // cache data folders
git init // local library initialization git
git remote add origin [SSH address] // set a remote repository
git pull origin master // pull data from a remote repository master, you need to enter the password you created when you create a .ssh
3. Other settings
3.1 modify the address of the warehouse
//method 1
git remote origin set -url [new SSH address] // modify the local remote repository
// Method 2
git remote rm origin // delete the local repository address
git remote add origin [new SSH address] // set local remote repository
// Method 3
Modify config files in your local library .git folder // url = [new SSH address]
3.2 Branch Management
git branch [new branch] // Create branch
git checkout [branch] // switch current branch corresponding local library
git push origin [branch] // push the corresponding branch
git branch -d [branch name to be deleted] // delete the local library branch
git push origin: [branch] // delete remote branch library
git branch // Check all the local library branch
git merge [other sub-branch name] // The other branches merge with the current branch, this time to change the current branch, other branches of the content does not change