Git上传和拉取项目源码

配置用户名和邮箱:

$git config --global user.name "your name"

$git config --global user.email "[email protected]"

建立本地git仓库

1. cd到你的项目目录

$ cd /Users/cjk/Desktop/myShop

输出如下:

$ git init 

Initialized empty Git repository in/Users/cjk/Desktop/GitTest/.git/

创建了一个空的本地仓库.

3.将项目的所有文件添加到缓存中:

$ git add . 

git add . (注意,后面有个点)表示添加目录下所有文件到缓存库,如果只添加某个文件,只需把 . 换成你要添加的文件名即可;

4.将缓存中的文件Commit到git库

git commit -m "添加你的注释,一般是一些更改信息"


下面是第一次提交时的输出:

$ git commit -m"添加项目"[master (root-commit) 3102a38] 添加项目

18files changed,1085insertions(+)

create mode 100644GitTest.xcodeproj/project.pbxproj

create mode 100644GitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata

create mode 100644GitTest.xcodeproj/project.xcworkspace/xcuserdata/Artron_LQQ.xcuserdatad/UserInterfaceState.xcuserstate

create mode 100644GitTest.xcodeproj/xcuserdata/Artron_LQQ.xcuserdatad/xcschemes/GitTest.xcscheme

create mode 100644GitTest.xcodeproj/xcuserdata/Artron_LQQ.xcuserdatad/xcschemes/xcschememanagement.plist

create mode 100644GitTest/AppDelegate.h

create mode 100644GitTest/AppDelegate.m

create mode 100644GitTest/Assets.xcassets/AppIcon.appiconset/Contents.json

create mode 100644GitTest/Base.lproj/LaunchScreen.storyboard

create mode 100644GitTest/Base.lproj/Main.storyboard

create mode 100644GitTest/Info.plist

create mode 100644GitTest/ViewController.h

create mode 100644GitTest/ViewController.m

create mode 100644GitTest/main.m

create mode 100644GitTestTests/GitTestTests.m

create mode 100644GitTestTests/Info.plist

create mode 100644GitTestUITests/GitTestUITests.m

create mode 100644GitTestUITests/Info.plist

最后上传远程git仓库。

git push -u origin master

如果想退出删除远程仓库项目,命令是:

Existing folder or Git repository

cd existing_folder

git init

git remote add origin “仓库名称”

git add .

git commit

git push -u origin master

//修改已经上传的文件内容,并再次重新提交

echo "修改的内容" > 文件名称

//查看内容做对比

$git diff

//接着提交已经修改的文件

$git commit -m "一些描述"

//提交到远程仓库

$git push -u origin master

你可能感兴趣的:(Git上传和拉取项目源码)