git Bash常用命令

1.Construct ssh key (If you want to commit to git server via THIS COMPUTER)

git config --global user.name " YOUR_USERNAME"
git config --global user.email "YOUR_EMAL@EMAIL.COM"
cd ~/.ssh
ssh-keygen -t rsa -C "YOUR_EMAIL@YOUREMAIL.COM"
【 then enter your passphrase

  after these operation , copy the content of "~/.ssh/id_rsa.pub" to the git server

2.Setup a new repository on your server

  Manually or via GUI      【 cz I don't know how to setup via bash :<

3.Commit your code to server

  If it's the first time you commit your code :

cd /your/source/code/folder
git init
git add .
git commit -m "first commit"
git remote add origin git@yourserver.com:username/project.git 
git push -u origin master

  Or if you have once commited :

git add .
git commit -m "second commit"
git push -u origin master

4.Clone your code from server to PC

cd /your/destination/directory
git clone git@yourserver.com:username/repository.git

Ref:

http://blog.csdn.net/it_yuan/article/details/8638321

http://www.cnblogs.com/wenjiang/p/3161682.html

http://stackoverflow.com/questions/10285198/git-clone-fatal-remote-error-access-denied-or-repository-not-exported

原文地址:https://www.cnblogs.com/pdev/p/4923751.html