Git 初始化Repository操作
2016-07-26 本文已影响180人
Thresh0ld
Command line instructions
Git global setup
git config --global user.name "UserName"
git config --global user.email "1234567890@qq.com"
Create a new repository
git clone http://gitlab.ddns.net/DrivingExam/DrivingExamApi.git
cd DrivingExamApi
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder or Git repository
cd existing_folder
git init
git remote add orign http://gitlab.ddns.net/DrivingExam/DrivingExamApi.git
git add .
git commit
git push -u origin master
注意:如果项目是用在XCode上的,建议在GitHub上创建项目时不要勾选创建ReadMe.md和.gitignore 不然的话在XCode上无法初始化推送。



当然,如果你嫌麻烦,完全可以按照下面的Git命令来操作。
以下是在GitHub上新建一个项目后GitHub提供的提示信息:
Quick setup — if you’ve done this kind of thing before
Set up in Desktop
or
HTTPS: https://github.com/wind0ws/HelloSwift.git
SSH: <git@github.com:wind0ws/HelloSwift.git>
We recommend every repository include a README, LICENSE, and .gitignore.
…or create a new repository on the command line
echo "# HelloSwift" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/wind0ws/HelloSwift.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/wind0ws/HelloSwift.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
Import code
