配置用戶名和郵箱:
$git config --global user.name "your name"
$git config --global user.email "xxx@163.com"
建立本地git倉庫
1. cd到你的項(xiàng)目目錄
$ cd /Users/cjk/Desktop/myShop
輸出如下:
$ git init?
Initialized empty Git repository in/Users/cjk/Desktop/GitTest/.git/
創(chuàng)建了一個空的本地倉庫.
3.將項(xiàng)目的所有文件添加到緩存中:
$ git add .?
git add . (注意,后面有個點(diǎn))表示添加目錄下所有文件到緩存庫,如果只添加某個文件,只需把 . 換成你要添加的文件名即可;
4.將緩存中的文件Commit到git庫
git commit -m "添加你的注釋,一般是一些更改信息"
下面是第一次提交時的輸出:
$ git commit -m"添加項(xiàng)目"[master (root-commit) 3102a38] 添加項(xiàng)目
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
最后上傳遠(yuǎn)程git倉庫。
git push -u origin master
如果想退出刪除遠(yuǎn)程倉庫項(xiàng)目慧起,命令是:
Existing folder or Git repository
cd existing_folder
git init
git remote add origin “倉庫名稱”
git add .
git commit
git push -u origin master
//修改已經(jīng)上傳的文件內(nèi)容菇晃,并再次重新提交
echo "修改的內(nèi)容" > 文件名稱
//查看內(nèi)容做對比
$git diff
//接著提交已經(jīng)修改的文件
$git commit -m "一些描述"
//提交到遠(yuǎn)程倉庫
$git push -u origin master