Git 初始化Repository操作

Command line instructions

Git global setup

git config --global user.name "UserName"
git config --global user.email "[email protected]"

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 初始化Repository操作_第1张图片
CreateNewRepository.png
Git 初始化Repository操作_第2张图片
XCodeSourceControl.png
Git 初始化Repository操作_第3张图片
AddRemote.png

当然,如果你嫌麻烦,完全可以按照下面的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:

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


关注我的公众号.jpg

你可能感兴趣的:(Git 初始化Repository操作)