首先在本地建立项目的文件夹,例如test_repo,使用git init初始化php
mkdir test_repo cd test_repo git init
建立一个文件,添加到git,而后提交git
touch test.txt git add test.txt git commit -m "test"
而后在github.com或者git.oschina.net上建立一个新的项目,建立以后会获得一个地址,相似git@git.oschina.net:yourname/test_repo.gitgithub
关联远程仓库bash
git remote add origin git@git.oschina.net:yourname/test_repo.git
下载远程代码.net
git pull origin master
提test.txt到远程仓库code
git push origin master
PS: git不容许提交空的目录,可是有时候咱们不得不添加空的目录,能够在目录下建立.gitignore文件,而后提交rem