第一部分:创建远程代码仓库
一、登录到git官网hub,新建一个版本仓库
二、在“Repository name”一栏里填写版本仓库的名称,如”test”,Description栏是描述,可填可不填。
默认访问权限为公共,点击”Creating Repository”按钮,即创建了版本仓库。
第二部分:本地代码提交
一、到官网下载客户端
二、输入cd +代码路径
三、输入git init (初始化版本仓库 .git隐藏文件)
四、输入git status (查看缓存区代码差异,红色是没有提交缓存区,绿色是已经提交)
五、输入git add . (提交缓存区代码)
六、输入git commit -m '注释'(给缓存区代码添加注释提交到本地master)
七、输入git remote (查看本地代码仓库和远程代码仓库关联情况)
八、输入git remote add origin +远程代码仓库地址 (关联)
九、输入git push origin master (把本地master提交到远程master)
十、输入git tag (查看标签)
十一、输入git tag -a '0.0.1' -m '注释'(打标签)
十二、输入git push --tags (提交所有标签)
十三、输入git log (查看版本号)
第三部分:修改代码提交
一、输入git status (查看)
二、输入git add . (提交本地代码仓库缓存区)
三、输入git commit -m ‘注释’ (提交本地代码仓库master)
四、输入git tag ‘0.0.2’ (打标签)
五、输入git push origin 0.0.2 (提交修改代码到远程仓库)
第四部分:删除远程代码仓库版本
一、输入git tag -d 0.0.1
二、输入git push origin :0.0.1
注释一:本地代码仓库分为:缓存区 + master
注释二:log是给代码加一条记录,关联版本号,而版本号关联代码,log相当于版本号的别名方便查看.
注释三:输入git remote --help (查看帮助命令)
Last login: Fri Mar 17 17:02:57 on ttys000
huidushudexiangjiao:~ lin$ cd /Users/lin/Desktop/demo/text
huidushudexiangjiao:text lin$ git init
Initialized empty Git repository in /Users/lin/Desktop/demo/text/.git/
huidushudexiangjiao:text lin$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
text.xcodeproj/
text/
textTests/
textUITests/
nothing added to commit but untracked files present (use "git add" to track)
huidushudexiangjiao:text lin$ git add .
huidushudexiangjiao:text lin$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: text.xcodeproj/project.pbxproj
new file: text.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file: text.xcodeproj/project.xcworkspace/xcuserdata/lin.xcuserdatad/UserInterfaceState.xcuserstate
new file: text.xcodeproj/xcuserdata/lin.xcuserdatad/xcschemes/text.xcscheme
new file: text.xcodeproj/xcuserdata/lin.xcuserdatad/xcschemes/xcschememanagement.plist
new file: text/AppDelegate.h
new file: text/AppDelegate.m
new file: text/Assets.xcassets/AppIcon.appiconset/Contents.json
new file: text/Base.lproj/LaunchScreen.storyboard
new file: text/Base.lproj/Main.storyboard
new file: text/Info.plist
new file: text/ViewController.h
new file: text/ViewController.m
new file: text/main.m
new file: textTests/Info.plist
new file: textTests/textTests.m
new file: textUITests/Info.plist
new file: textUITests/textUITests.m
huidushudexiangjiao:text lin$ git commit -m 'xxx'
[master (root-commit) c91a6f6] xxx
Committer: JingQinglin <lin@huidushudexiangjiao.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
18 files changed, 1067 insertions(+)
create mode 100644 text.xcodeproj/project.pbxproj
create mode 100644 text.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create mode 100644 text.xcodeproj/project.xcworkspace/xcuserdata/lin.xcuserdatad/UserInterfaceState.xcuserstate
create mode 100644 text.xcodeproj/xcuserdata/lin.xcuserdatad/xcschemes/text.xcscheme
create mode 100644 text.xcodeproj/xcuserdata/lin.xcuserdatad/xcschemes/xcschememanagement.plist
create mode 100644 text/AppDelegate.h
create mode 100644 text/AppDelegate.m
create mode 100644 text/Assets.xcassets/AppIcon.appiconset/Contents.json
create mode 100644 text/Base.lproj/LaunchScreen.storyboard
create mode 100644 text/Base.lproj/Main.storyboard
create mode 100644 text/Info.plist
create mode 100644 text/ViewController.h
create mode 100644 text/ViewController.m
create mode 100644 text/main.m
create mode 100644 textTests/Info.plist
create mode 100644 textTests/textTests.m
create mode 100644 textUITests/Info.plist
create mode 100644 textUITests/textUITests.m
huidushudexiangjiao:text lin$ git remote
huidushudexiangjiao:text lin$ git remote add origin https://github.com/JiQingLin/text.git
huidushudexiangjiao:text lin$ git remote
origin
huidushudexiangjiao:text lin$ git push origin master
Counting objects: 32, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (27/27), done.
Writing objects: 100% (32/32), 15.50 KiB | 0 bytes/s, done.
Total 32 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/JiQingLin/text.git
* [new branch] master -> master
huidushudexiangjiao:text lin$ git tag
huidushudexiangjiao:text lin$ git tag -a '0.0.1' -m '打标签'
huidushudexiangjiao:text lin$ git tag
0.0.1
huidushudexiangjiao:text lin$ git push --tags
Counting objects: 1, done.
Writing objects: 100% (1/1), 184 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/JiQingLin/text.git
* [new tag] 0.0.1 -> 0.0.1
huidushudexiangjiao:text lin$ git log
commit c91a6f6919a037cee4e2420399b01535d1528a97
Author: JingQinglin <lin@huidushudexiangjiao.local>
Date: Fri Mar 17 17:56:05 2017 +0800
xxx
huidushudexiangjiao:text lin$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: text/ViewController.m
no changes added to commit (use "git add" and/or "git commit -a")
huidushudexiangjiao:text lin$ git add .
huidushudexiangjiao:text lin$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: text/ViewController.m
huidushudexiangjiao:text lin$ git commit -m '修改'
[master ab77ca3] 修改
Committer: JingQinglin <lin@huidushudexiangjiao.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 2 deletions(-)
huidushudexiangjiao:text lin$ git log
commit ab77ca3e0104923bb21ca15471da73eb79412e44
Author: JingQinglin <lin@huidushudexiangjiao.local>
Date: Fri Mar 17 18:29:23 2017 +0800
修改
commit c91a6f6919a037cee4e2420399b01535d1528a97
Author: JingQinglin <lin@huidushudexiangjiao.local>
Date: Fri Mar 17 17:56:05 2017 +0800
xxx
huidushudexiangjiao:text lin$ git tag '0.0.2'
huidushudexiangjiao:text lin$ git tag
0.0.1
0.0.2
huidushudexiangjiao:text lin$ git push origin 0.0.2
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 363 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/JiQingLin/text.git
* [new tag] 0.0.2 -> 0.0.2
huidushudexiangjiao:text lin$ git tag
0.0.1
0.0.2
huidushudexiangjiao:text lin$ git tag -d 0.0.1
Deleted tag '0.0.1' (was 96bbe56)
huidushudexiangjiao:text lin$ git tag
0.0.2
huidushudexiangjiao:text lin$ git push origin :0.0.1
To https://github.com/JiQingLin/text.git
- [deleted] 0.0.1
huidushudexiangjiao:text lin$