diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000..d95da94821 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..211779b153 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ +asdasd +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Project file +*.project +*.pydevproject +asdasd + +my_git diff --git a/.xlshlr_git command.txt b/.xlshlr_git command.txt new file mode 100644 index 0000000000..80608eafa8 --- /dev/null +++ b/.xlshlr_git command.txt @@ -0,0 +1,62 @@ +$ git config --global user.name "xlshlr" +$ git config --global user.email "xlshlr@163.com" +$ git init +$ git add readme.txt +$ git add file2.txt file3.txt +$ git commit -m "wrote a readme file" +$ git status +$ git diff readme.txt +$ git log --pretty=oneline +$ git reset --hard HEAD^ +$ git reset --hard 3628164 +$ git reflog +$ git diff HEAD -- readme.txt +$ git checkout -- readme.txt +$ git rm test.txt +$ git remote add origin https://github.com/xlshlr/firstblood.git +$ git push -u origin master + +$ git checkout -b dev +$ git branch dev +$ git checkout dev +$ git checkout master +$ git merge dev +$ git branch -d dev +$ git branch -D feature-vulcan + +git log --graph +$ git merge --no-ff -m "merge with no-ff" dev +$ git log --graph --pretty=oneline --abbrev-commit +$ git stash +$ git stash list +git stash apply +git stash drop +$ git stash pop +$ git stash apply stash@{0} +$ git push origin dev:dev // 提交本地dev分支作为远程的dev分支 + +$ git push origin :dev // 刚提交到远程的dev将被删除,但是本地还会保存的,不用担心 +$ git push origin dev +$ git remote +$ git branch --set-upstream dev origin/dev +$ git tag v1.0 +$ git tag +$ git tag v0.9 6224937 +$ git show v0.9 +$ git tag -a v0.1 -m "version 0.1 released" 3628164 +$ git tag -s v0.2 -m "signed version 0.2 released" fec145a +$ git push origin v1.0 +$ git push origin --tags +$ git tag -d v0.9 +$ git push origin :refs/tags/v0.9 + + + + + + + + + + +git push -u origin master \ No newline at end of file diff --git a/000ooo000.i b/000ooo000.i new file mode 100644 index 0000000000..7bb13b5b21 --- /dev/null +++ b/000ooo000.i @@ -0,0 +1,7 @@ +.Ϊ,κάֺ߱ϵ?githubϵ: +1.ά߿ݵֿ blessed repository +2.߿¡˹ֿ(blessed repository)ԼĹֿdeveloper public(ֿgihubԼһgit,֪ͨάȡ´).(fork). +3.¡ԼĹֿ⵽ؿ⿪,ԼĹֿdeveloper-public. +4.pull requestά.(ά߷ʼȡԼ´.) +5.άԼص integration manger ֿУߵĹֿΪԶֿ̲⣬ϲ².һgithub֪άô?integration mangerнblessed repositoryֱgithubվ ֶ? +6.ά߽ϲĸ͵ֿ blessed repository diff --git a/1024.cpp b/1024.cpp new file mode 100644 index 0000000000..2c590d21c0 --- /dev/null +++ b/1024.cpp @@ -0,0 +1,5 @@ +#include +int main(){ + std::cout << "1024" << std::endl; + return 0; +} diff --git a/11447416.txt b/11447416.txt new file mode 100644 index 0000000000..c4426ce62c --- /dev/null +++ b/11447416.txt @@ -0,0 +1,3 @@ +To sey learn ,I will say git is good,i must learn it will + then thanks Mr.Liao write the article. + diff --git a/2 b/2 new file mode 100644 index 0000000000..cfbacb455f --- /dev/null +++ b/2 @@ -0,0 +1,4 @@ +thanks +for your help + + diff --git a/20150427add.txt b/20150427add.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/304270703@qq.com b/304270703@qq.com new file mode 100644 index 0000000000..4af1ada830 --- /dev/null +++ b/304270703@qq.com @@ -0,0 +1 @@ +Thanks for your articles. diff --git a/454135329@qq.com b/454135329@qq.com new file mode 100644 index 0000000000..2a5b82bacd --- /dev/null +++ b/454135329@qq.com @@ -0,0 +1 @@ +git真的蛮好的,是我使用过最好的版本控制软件,感谢老师的帮助。 diff --git a/521xueweihan.txt b/521xueweihan.txt new file mode 100644 index 0000000000..45a563e330 --- /dev/null +++ b/521xueweihan.txt @@ -0,0 +1,2 @@ +最后一个测!let‘go! +再测试一次 \ No newline at end of file diff --git a/Annabel.txt b/Annabel.txt new file mode 100644 index 0000000000..472ecb0eaf --- /dev/null +++ b/Annabel.txt @@ -0,0 +1 @@ +晴天好心情!Thank you! diff --git a/Aragron.txt b/Aragron.txt new file mode 100644 index 0000000000..c0a5b40722 --- /dev/null +++ b/Aragron.txt @@ -0,0 +1,4 @@ +I am really excited! +I can see soo high quality material in Internet! +Really Thankyou , liao! +It is amazing!!! \ No newline at end of file diff --git a/ArielWorld_github.txt b/ArielWorld_github.txt new file mode 100644 index 0000000000..c457ad54ba --- /dev/null +++ b/ArielWorld_github.txt @@ -0,0 +1 @@ +I still don't know how to pull request. \ No newline at end of file diff --git a/AyumuAkira.txt b/AyumuAkira.txt new file mode 100644 index 0000000000..5814c2498a --- /dev/null +++ b/AyumuAkira.txt @@ -0,0 +1 @@ +Thanks for sharing very much. \ No newline at end of file diff --git a/BLUE-V.txt b/BLUE-V.txt new file mode 100644 index 0000000000..49cd706aa1 --- /dev/null +++ b/BLUE-V.txt @@ -0,0 +1,2 @@ +thank you liao + - from 白兰度 diff --git a/Best.txt b/Best.txt new file mode 100644 index 0000000000..6d5b02179a --- /dev/null +++ b/Best.txt @@ -0,0 +1,3 @@ +"Helo, word" + + thank you!!! diff --git a/BlueIceQ.txt b/BlueIceQ.txt new file mode 100644 index 0000000000..16165e28b6 --- /dev/null +++ b/BlueIceQ.txt @@ -0,0 +1,2 @@ +廖大大的教程很接地气,很实用,简单易学,容易上手. +希望关于java1.8的教程也快快能够看到. diff --git a/CTextBox.cs b/CTextBox.cs new file mode 100644 index 0000000000..2f4da125fd --- /dev/null +++ b/CTextBox.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Linq.Expressions; +using Zwj.TEMS.Common; + + +namespace TEMS.Controls +{ + /// + /// 文本框 + /// Author:Wheeky + /// Url:www.zuowenjun.cn + /// + public partial class CTextBox : UserControl,IZwjDefControl + { + [Description("当点击按钮时触发该事件")] + public event EventHandler OnOpen; + + [Description("当值改变时触发该事件")] + public event EventHandler OnValueChange; + + public CTextBox() + { + InitializeComponent(); + this.DispalyOpenButton = false; + textBox1.TextChanged += delegate { RaiseValueChange(); }; + } + + private void RaiseValueChange() + { + if (this.OnValueChange!=null) + { + this.OnValueChange(this, null); + } + } + + [Browsable(true)] + [Description("设置文本框的值")] + public string Value + { + get + { + return textBox1.Text; + } + set + { + textBox1.Text = value; + } + } + + [Browsable(true)] + [Description("设置标签的值")] + public string Label + { + get + { + return label1.Text; + } + set + { + label1.Text = value; + } + } + + [Browsable(true)] + [Description("设置是否显示打开按钮")] + public bool DispalyOpenButton + { + get + { + return button1.Visible; + } + set + { + button1.Visible = value; + textBox1.ReadOnly = button1.Visible; + } + } + + [Browsable(true)] + [Description("设置是否允许多行")] + public bool AllowMultiline + { + get + { + return textBox1.Multiline; + } + set + { + textBox1.Multiline = value; + if (textBox1.Multiline) + { + textBox1.ScrollBars = ScrollBars.Vertical; + } + } + } + + [Browsable(true)] + [Description("设置屏蔽密码的字符")] + public char PasswordChar + { + get + { + return textBox1.PasswordChar; + } + set + { + textBox1.PasswordChar=value; + } + } + + public void ValueFor(Expression> selectField, string fieldValue, bool displayBtn = false, bool allowMultiline=false) where TEntity : class + { + var fieldInfo = General.GetPropertyInfo(selectField); + this.Label = General.GetDisplayName(fieldInfo); + this.Value = fieldValue; + this.DispalyOpenButton = displayBtn; + this.AllowMultiline = allowMultiline; + } + + private void button1_Click(object sender, EventArgs e) + { + if (this.OnOpen != null) + { + this.OnOpen(this, null); + } + } + } +} diff --git a/ChanShuYi.txt b/ChanShuYi.txt new file mode 100644 index 0000000000..17f5d64f55 --- /dev/null +++ b/ChanShuYi.txt @@ -0,0 +1,6 @@ +Thanks for your asesome Git Lesson. It help us open the eyes to the open source project world. I use two day's time to learn how to use git through your leasson. I really like your word of your Git Lesson and it's so easy to understand. + +All in all, I hope you have a better life and write more useful and high-qualified lesson. + +Thank you again. +Thank you again. diff --git a/ChunleiGuo_pull_request.txt b/ChunleiGuo_pull_request.txt new file mode 100644 index 0000000000..8fc2d66b1f --- /dev/null +++ b/ChunleiGuo_pull_request.txt @@ -0,0 +1,3 @@ +This is a 'pull_request' test from ChunleiGuo, +and I have learnt a lot about Git from Mr Liao. +Thank you! \ No newline at end of file diff --git a/ColinPullTest.txt b/ColinPullTest.txt new file mode 100644 index 0000000000..bc74dab9c8 --- /dev/null +++ b/ColinPullTest.txt @@ -0,0 +1,2 @@ +This is Colin's Txt +This is my code! diff --git a/ContinueCoding.txt b/ContinueCoding.txt new file mode 100644 index 0000000000..c30ac7edb2 --- /dev/null +++ b/ContinueCoding.txt @@ -0,0 +1,5 @@ +GitHub Fork测试! +Git学习心得 + 暂时跟着廖雪峰大神的Git教程学习,虽然是用Git Bash敲命令行, +但没有想象的枯燥,教程浅显易懂,循序渐进,非常有收获!希望在接 +下来的学习中对Git的强大有更好的体会,Fighting!!! \ No newline at end of file diff --git a/DarrencenZ.txt b/DarrencenZ.txt new file mode 100644 index 0000000000..b41c1e7f06 --- /dev/null +++ b/DarrencenZ.txt @@ -0,0 +1,2 @@ +谢谢您的GIT教程,很实用。 +只不过公司目前做代码管理还是基于SVN,由于刚开始实习,还未感受到SVN的不便之处,但是内心认为GIT是趋势,谢谢您的教程. diff --git a/DentistXu.txt b/DentistXu.txt new file mode 100644 index 0000000000..e366eada6a --- /dev/null +++ b/DentistXu.txt @@ -0,0 +1,7 @@ +Very Cool tutorials. Easy to read. Leaned a lot. + +Above is added in master branch. + +Bellow is added in a new branch dev, just for a test. + +michaelliao is a nice person and a very good mentor. diff --git a/Dingshijie.txt b/Dingshijie.txt new file mode 100644 index 0000000000..01bda02be4 --- /dev/null +++ b/Dingshijie.txt @@ -0,0 +1,2 @@ +Thank you for sharing. And i will recommend the web site to others. +Best wishes! diff --git a/Dmicc b/Dmicc new file mode 100644 index 0000000000..710deb8fa4 --- /dev/null +++ b/Dmicc @@ -0,0 +1 @@ +Thanks a lot. diff --git a/DwyaneTalk.txt b/DwyaneTalk.txt new file mode 100644 index 0000000000..9ab1fc1743 --- /dev/null +++ b/DwyaneTalk.txt @@ -0,0 +1,2 @@ +非常感谢老师,通过您这份教程,我对Git有了更加全面的认识,相信这份教程一定会帮助很多人的,支持老师 +PS:刚刚陷入文字编码的坑,原来在bash里新建文件之后,使用vi打开编辑,会以ANSI格式编码…… \ No newline at end of file diff --git a/Engineering-Course.txt b/Engineering-Course.txt new file mode 100644 index 0000000000..9f9e5a99aa --- /dev/null +++ b/Engineering-Course.txt @@ -0,0 +1,5 @@ +I'm surprised to find such a good tutorial. +I knew nothing about git before I read it. +But now, I can't wait to work with git. +The turorial is easy to understand. +Thank you very much. \ No newline at end of file diff --git a/Farb.txt b/Farb.txt new file mode 100644 index 0000000000..ec3ca3890e --- /dev/null +++ b/Farb.txt @@ -0,0 +1,12 @@ +***************Git学习心得******************** + 你好,Michael,很高兴认识你这位大牛!我是一名大四学生, +广州读的大学,现在在杭州实习,来到杭州也是为了追求自己心爱的女孩。 +今天是星期日,不算很冷吧,但我依然坐在床上看着你的Git教程。之前对VCS一点都不了解, +只知道只是个版本控制系统的英文单词,具体怎么用真的找不到入门的好资料,几天在coding.net这个 +网站【类似于中国版的GitHub】的帮助说明中看到了他们推荐了你的教程,这才无意认识了你这个教我Git入门的师傅。 +从早上一直看到现在,还没看完,还差一点点了,但是明天还要早起来上班,所以今晚就写完这个心得就洗洗睡了。 +感觉学到了很多,而且不知道是因为动了脑子还是怎地,今晚胃口大开,吃了好多,一碗面加一盘鸡腿套餐,哈哈! +现在在公司,主管让我用的TortoiseSVN,感觉已经上手了,今天再来学习你的Git感觉还不算很难,也可能是你讲的浅显易懂吧! +好吧,听你的忠告,以后就要Git了,明天就劝主管让他改用Git,还能剩下租用阿里云服务器的费用哈哈!晚安!我给你 +发的pullrequest 你一定要接受哦! +***************Git学习心得******************** \ No newline at end of file diff --git a/GitOfHalu126.txt b/GitOfHalu126.txt new file mode 100644 index 0000000000..27529c78d7 --- /dev/null +++ b/GitOfHalu126.txt @@ -0,0 +1,77 @@ +1、git init:初始化一个Git仓库。 +2、添加文件到Git仓库,分两步: + 第一步,使用命令git add ,注意,可反复多次使用,添加多个文件; + 第二部,使用命令git commit -m "提交说明",完成。 +3、git status:打印整个工作区的状态。 +4、git diff :查看修改内容。 +5、git log:查看系统中的历史commit提交记录 + 如:git log 或git log --pretty=oneline + 其中pretty指定打印提交记录内容的格式,可选的值有:oneline,short,medium,full,fuller,email,raw和一些自定义的字符格式。 + 补充: + --graph可以看到分支合并图。 + --abbrev-commit打印简短commit-id。 +6、git reset --hard :将head的值设定为指定的commit_id, + HEAD表示当前版本id, + HEAD^表示上一个版本id, + HEAD^^表示上上一个版本id, + HEAD~100表示上上100个版本id, + 版本id也可以在git log命令中查看,commit就是。 +7、git reflog:记录你的每一次有关head的历史命令记录 +8、工作区(Working Directory):就是当前的工作目录。 + 版本库(Repository):工作区下的隐藏目录.git。 + 暂存区(stage):版本库中的index(或者是stage)文件。 + git add命令就是把文件修改添加到暂存区(stage)中; + git commit命令就是把暂存区的所有内容提交到当前分支中。(如下图) + +9、git checkout -- :把工作区中对filename文件的修改撤销掉 + 这里有两种情况: + 一种是修改后还没放到暂存区(即:还没有使用git add命令),现在撤销修改就是回到和版本库一模一样的状态; + 一种是已经添加到暂存区后,又作了修改,现在撤销修改就是回到添加到暂存区后的状态。 + 总之,就是让这个文件回到最近一次git commit或git add时的状态 + 补充: + git checkout :切换到相应的分支上。 +10、git reset HEAD :把暂存区中对filename的修改撤销掉(此步是把修改从暂存区撤销到工作区,要想撤销工作区的修改,要进一步的使用git checkout -- 命令) + 如果修改已经提交到版本库中了,在没有把本地版本推送到远程的情况下可以使用git reset --hard 命令进行版本回退了。 +11、git rm :在暂存区记录下要删除文件filename,使用git commit命令提交删除申请,从版本库中删除文件。 +12、ssh-keygen -t rsa -C "youremail@example.com":使用自己的邮件在用户主目录下生成SSH key。(要在主目录下运行此命令) + -t 指定加密方式,可以值有:rsa、dsa,默认为:dsa + -C是添加注解comment,可以不是自己的邮件,也可以不要此项。 +13、git remote add origin git@github.com:/<仓库名>.git 将本地仓库与github上的仓库关联起来。 + origin为远程库的名字。 +14、git push -u origin master:将本地库的所有内容推送到远程库上。(只有第一次推送的时候才加上-u) +15、git config --global user.name "用户名":配置缺省的用户名。 +16、git config --global user.email "":配置缺省的email,最好和注册时使用一样的email。 +17、git clone git@github.com:<用户名>/<仓库名>.git:从远程库中克隆版本库到本地。 +18、git branch:查看分支。 + 补充: + git branch --set-upstream branch-name origin/branch-name:创建本机分支与远程分支的链接关系。 +19、git branch :创建分支name。 +20、git checkout :切换到分支name。 +21、git checkout -b :创建并切换到分支name。 +22、git merge :合并name分支到当前分支中。 + 如果合并的时候产生了冲突,git会告诉我们在哪个文件上产生了冲突(git status也会告诉我们冲突的文件),必须手动解决冲突后在提交。 + 补充: + --no-ff参数表示禁止使用Fast forward模式合并,应为本次合并要创建一个新的commit,所以要加入-m,将commit描写写进去。 +23、git branch -d :删除分支name。 + 补充: + git branch -D :强行删除那么分支。 +24、git stash:把当前工作现场储藏到工作栈中(入栈操作)。 +25、git stash list:查看储藏工作现场的栈里的内容。 +26、git stash apply stash@{n}:将工作栈中的第n个工作现场回复出来。 +27、git stash drop:删除工作栈中第一个工作现场。 +28、git stash pop:回复工作现场的同时把相应的内容从工作栈中删除。(出栈操作)。 +29、git remote:查看远程库信息。 + -v:查看远程库详细信息,其中fetch是抓取地址;push是推送地址。 +30、git pull:把别人最新的提交从远程上抓取下来。 +31、git tag [commit-id]:在commit-id处创建一个标签,commit-id默认为HEAD。 + -a tagname -m "blablabla...":指定标签信息。 + -s tagname -m "blablabla..." :可以使用PGP签名标签。 +32、git tag:查看所有标签。 +33、git show :查看标签详细信息。 +34、git tag -d :删除本地标签。 +35、git push origin :refs/tags/tagname:删除一个远程标签。 +36、git push origin origin tagname:推送标签到远程。 +37、git push origin --tags:推送全部标签到远程。 +38、.gitignore文件:忽略特殊文件,https://github.com/github/gitignore。 + +大家辛苦了,comment里面欣赏下美女吧! diff --git a/Git_Commands@pengloo53.md b/Git_Commands@pengloo53.md new file mode 100644 index 0000000000..847adcb3ee --- /dev/null +++ b/Git_Commands@pengloo53.md @@ -0,0 +1,98 @@ +--- + +layout: post +title: "Git 常用命令" + +--- +###学会这些命令,你就可以熟练的使用Git工具了,什么?想精通,那是不可能的。 +####基本上,Git就是以下面的命令顺序学习的。文中笔记是从廖雪峰老师的[Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000)中总结出来的,方面查阅命令。详细原理请看[Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000) +####1、基础 +- `git config --global user.name "Your Name"`设置你的仓库用户名(用于标识提交者) +- `git config --global user.email "email@example.com"`设置你的仓库邮箱(用于标识提交者) +- `git init` 初始化一个git仓库 +- `git add --all` 添加所有更改的文件 +- `git add filename1` 当然可以指定添加filename1 +- `git commit -m "commit message"` 添加更改的信息,必须要有,不然报错,不建议不加。 +- `git status` 查看git当前状态 +- `git diff filename1` 查看filename1到底修改了哪些内容 +- `git log` 查看最近的提交日志 +- `git log --pretty=oneline` 单行显示提交日志 +- `git reset --hard commitID` 利用`git log`得到的commitID返回版本 +- `git reset --hard HEAD^`回到上一个版本 +- `git reflog` 查看命令的历史,可以找到`git log`看不到的commitID,因为`git log`只显示当前的提交日志,如果你提交了一次,退回版本后又后悔了,就能查看上次提交的commitID +- `git checkout -- filename1` 利用版本库中的版本替换工作区中的文件。功能有2: + - 撤销文件修改,分两种情况: + - 撤销工作区中的修改(没有使用`git add`命令添加到暂存区) + - 撤销暂存区中的修改(添加到了暂存区又做了修改) + - 找回删除的文件 + - 工作区中文件误删了,可以通过此命令从版本库中找回 +- `git reset HEAD filename1` 撤销add,回到工作区 +- `git rm filename1` 删除文件 +- `git remote add origin https://github.com/pengloo53/learngit.git` 将本地库关联到github远程库上 +- `git push -u origin master` 第一次推送的时候要加上`-u`参数,可以将本地库的master分支与远程库的master分支关联起来;下次提交就不需要加`-u`了。 +- `git clone https://github.com/pengloo53/learngit.git` 克隆远程库到本地 + +####2、分支管理 +- `git checkout -b dev`创建dev分支并切换到dev。相当于`git branch dev`、`git checkout dev`两条命令。 +- `git branch`查看当前分支 +- `git merge dev`合并指定分支到当前分支,如,你现在master分支,那么执行命令就将dev分支合并到了master分支上。 +- `git branch -d dev`删除dev分支 +- `git log --graph --pretty=oneline --abbrev-commit`查看分支合并图 +- `git merge --no-ff -m "merge with no-ff" dev`禁用「Fast forward」,也就是保留分支的相关信息。 +- `git stash` 将工作区现场储藏起来,等以后恢复后继续工作。通常用于处理更为着急的任务时,例如:bug。 +- `git stash list` 查看保存的工作现场 +- `git stash apply`恢复工作现场 +- `git stash drop` 删除stash内容 +- `git stash pop` 恢复的同时直接删除stash内容 +- `git stash apply stash@{0}` 恢复指定的工作现场,当你保存了不只一份工作现场时。 +- `git branch -D feature-vulcan` 强行删除分支。用于不需要合并,就地删除的情况。 +- `git remote` 查看远程库的信息,一般返回origin。 +- `git remote -v` 查看远程库的详细信息。 +- `git push origin master` 将本地master分支推送到远程master分支。 + - master分支为主分支,因此要时刻与远程同步; + - dev分支为开发分支,团队成员都需要在上面工作,所以也需要与远程同步; + - bug分支只用于在本地修复bug,没有必要推送到远程; + - feature新功能分支是否推送到远程,取决于你是否和其他人合作在上面开发。 +- `git clone https://github.com/pengloo53/learngit.git` 将远程库克隆到本地,默认只能看到master分支。 +- `git checkout -b dev origin/dev` 创建远程dev分支到本地 +- `git pull` 将远程分支的最新内容抓取下来。 +- `git branch --set-upstream dev origin/dev`将本地dev分支与远程dev分支之间建立链接。 + +#####_多人协作工作模式_ +1. 首先,可以试图用`git push origin branch-name`推送自己的修改; +2. 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并(如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令`git branch --set-upstream branch-name origin/branch-name`); +3. 如果合并有冲突,则解决冲突,并在本地提交; +4. 没有冲突或者解决掉冲突后,再用`git push origin branch-name`推送就能成功! + +####3、标签管理 +- `git tag v1.0` 给当前分支打上标签 +- `git tag` 查看所有的标签,按时间顺序列出。 +- `git log --pretty=oneline --abbrev-commit`缩略commitID并单行显示提交信息 +- `git tag v0.9 commitID`通过上一条命令查看commitID,然后打上标签。用于忘记打标签的情况,因为标签其实就是只想某个commitID的指针,默认情况下,标签打在最新的提交上。 +- `git show v0.9` 查看标签信息。 +- `git tag -a v0.1 -m "version 0.1 released" commitID`创建带有说明的标签,`-a`指定标签名,`-m`指定说明文字。 +- `git tag -d v0.1` 删除标签v0.1 +- `git push origin v1.0` 推送标签1.0到远程 +- `git push origin --tags` 推送所有的标签到远程 +- `git push origin :refs/tags/v0.9` 删除远程标签,但是前提是要先在本地删除对应标签。 + +####4、自定义GitHub +- `git config --global color.ui true` 让Git显示颜色 +- `.gitignore`在这个文件里编辑你要忽略的文件,并提交到Git中,就可以忽略特殊文件的检查。如将`*.db`写入`.gitignore`文件中,将忽略所有db文件。可以参考[github收集的所有.gitignore](https://github.com/github/gitignore) +- `git config --global alias.st status`将status的别名设置成st,那么`git st`=`git status`。 +- `git config --global alias.unstage 'reset HEAD'` 那么`git reset HEAD filename`=`git unstage filename` +- `git config --global alias.last 'log -1'` 敲`git last`就显示最后一次提交了。 + +####5、搭建Git服务器 +1. `sudo apt-get install git` 安装Git; +2. `sudo adduser git` 添加Git用户; +3. `sudo git init --bare sample.git` 初始化git仓库; +4. `sudo chown -R git:git sample.git`修改仓库的所属用户为git; +5. 将git用户的信息`git:x:1001:1001:,,,:/home/git:/bin/bash`改成`git:x:1001:1001:,,,:/home/git:/bin/git-shell`,为了禁用shell登录。 +6. `git clone git@server:/director/sample.git` 克隆Git服务器上的仓库 + +_PS. 想方便管理公钥,用[Gitosis](https://github.com/res0nat0r/gitosis);想控制权限,用[Gitolite](https://github.com/sitaramc/gitolite)。_ + + + + diff --git a/GreenLim.txt b/GreenLim.txt new file mode 100644 index 0000000000..904ff23594 --- /dev/null +++ b/GreenLim.txt @@ -0,0 +1 @@ +thanks a lot for these wonderful feeds! \ No newline at end of file diff --git a/Horve.txt b/Horve.txt new file mode 100644 index 0000000000..a7006d4ca6 --- /dev/null +++ b/Horve.txt @@ -0,0 +1,198 @@ +创建版本库 + +$ git init +把目录变成Git可以管理的仓库(Git仓库) + +$ git add file +把file文件添加到仓库 + +$ git commit -m ‘commit logic’ +将暂存区内的改动提交到仓库,并加上’commit logic’的提交日志 + +$ git status +仓库的状态,包括有无修改,是否已经完全提交到仓库 + +$ git diff file +暂存区和版本库中file文件的区别 + + +版本回退 + +$ git log +仓库内文件的修改日志 + +$ git reset --hard HEAD^ +回退到上一个版本 + +$ git reset --hard HEAD^^ +回退到倒数第二个版本 + +$ git reset --hard HEAD~100 +回退到倒数第100个版本 + +$ git reset --hard ‘commit_id’ +根据git log命令得到的结果中的commit_id,回退到对应版本(commit_id只写前几位就行) + +$ git reflog +记录每一次命令 + +注:Gti的版本回退速度非常快,因为Git在内部有个指向当前版本的HEAD指针,当你回退版本的时候,Git仅仅是把HEAD指针从原始版本指向当前版本。HEAD指向的版本始终是当前版本。 + +管理修改 + +$ git diff HEAD -- file +工作区和版本库里file文件最新版的区别 + +$ git checkout -- file +把file在工作区中的更改全部撤销。PS: “--”很重要,没有“—”就变成了一个创建新分支的命令。 + +$ git reset HEAD file +把file在暂存区中的修改全部撤销(unstage),重新放回工作区(就是回到git add命令之前)。 + +$ rm file +从工作区中删除文件,不能影响版本库 + +$ git rm file +从版本库中删除文件,并且要git commit提交改动 + +github + +$ git remote add origin ‘git-ssh-url’ +把一个本地仓库与GitHub仓库关联 + +$ git push -u origin master +第一次推送master分支的所有内容【把本地库的内容推送到远程库上】 + +$ git push origin master  +每次本地提交后,都能使用改名了推送到远程库 + +$ git clone ‘git-ssh-url’ +从远程库克隆一个本地库 + +PS:GitHub给出的地址不止一个,还可以用https://github.com/xxxxx/xxxx.git这样的地址。实际上,Git支持多种协议,默认的git://使用ssh,但也可以使用https等其他协议。 + +使用https除了速度慢以外,还有个最大的麻烦是每次推送都必须输入口令,但是在某些只开放http端口的公司内部就无法使用ssh协议而只能用https。 + +与远程版本库关联并同步文件的流程: +1,创建SSH Key并对GitHub进行配置; +2,在GitHub上创建远程库; +3,本地目录通过git init,git add, git commit等命令将本地目录配置成Git仓库,并提交更新; +4,git remote add origin ‘git-ssh-url’命令将本地库与远程库关联; +5,git push -u origin master命令将本地库所有的内容推送到远程库,第一次带-u,以后不用带。 + +创建与合并分支 + +$ git branch -b dev +创建并切换到分支dev + +$ git branch dev +创建分支dev + +$ git checkout dev +切换到分支dev + +$ git branch  +列出所有分支,并标示出当前分支 + +$ git merge dev +把dev分支的结果合并到当前分支 + +$ git branch -d dev +删除dev分支 + +$ git log --graph +查看分支合并图 + +$ git merge --no-ff -m “no-ff merge” dev +通过no-ff模式(非Fast forward模式)合并dev分支到当前分支 + +PS:通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息 +如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息,也就是合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + +Bug分支 + +$ git stash  +存储当前工作现场,修复bug后恢复工作现场 + +$ git stash list +查看所有存储的工作现场 + +$ git stash apply +恢复所有的工作现场 + +$ git stash pop +删除所有的工作现场 + +$ git stash apply stash@{N}  +恢复指定的工作现场 + +$ git branch -D dev +强行删除没有被合并的分支dev + +多人协作 + +$ git remote +查看远程库信息 + +$ git remote -v +查看远程库更多信息,如: +origin git@github.com:Horve/ws-exam.git (fetch) +origin git@github.com:Horve/ws-exam.git (push) +PS:上面显示了可以抓取和推送的origin的地址。如果没有推送权限,就看不到push的地址。 + +$ git push origin master +将master分支上所有的本地提交推送到远程库 + +抓取分支 + +团队成员从远程库clone时,默认情况下,他将只能看到本地的master分支。如果需要在其他的分支上进行开发,就需要创建远程origin的其他分支到本地。 + +$ git checkout -b dev origin/dev +创建远程的dev分支到本地 + +$ git branch --set-upstream dev origin/dev +建立本地分支与远程分支之间的链接/关联 + +多人协作的工作模式 + +1,首先,可以试图用git push origin branch-name推送自己的修改; +2,如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; +3,如果合并有冲突,则解决冲突,并在本地提交; +4,没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! +5,如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +创建标签 + +$ git tag v1.0 +为当前分支创建标签v1.0,默认为HEAD创建 + +$ git tag +查看分支所有标签(标签不是按时间顺序列出,而是按字母排序的) + +$ git tag v0.9 commit_id +为对应的commit版本创建标签(可通过git log查看commit日志获取对应版本的commit_id) + +$ git show v0.9 +根据标签查找对应的版本 + +$ git tag -a v1.0 -m “version 1.0 released” commit_id +创建带有说明的标签,-a指定标签名,-m指定说明文字 + +操作标签 + +$ git tag -d v1.0 +删除标签。创建的标签都只存储在本地,不会自动推送到远程。所以打错的标签可以在本地安全删除。 + +$ git push origin v1.0 +推送v1.0标签到远程版本库 + +$ git push origin --tags +一次性推送全部尚未推送到远程的本地标签 + +删除远程标签 + +$ git tag -d v0.9 +首先删除本地标签 + +$ git push origin :refs/tags/v0.9 +然后用这条命令删除远程标签 \ No newline at end of file diff --git a/HsingChin.txt b/HsingChin.txt new file mode 100644 index 0000000000..4d5b341482 --- /dev/null +++ b/HsingChin.txt @@ -0,0 +1,2 @@ +Dear Michael: + This Git lesson is very helpful, thanks a lot, it was you who show me the door to the amazing world of git. diff --git a/HuChengzhen.txt b/HuChengzhen.txt new file mode 100644 index 0000000000..8307abdc6f --- /dev/null +++ b/HuChengzhen.txt @@ -0,0 +1 @@ +跟着这个教程学习,感觉很棒 \ No newline at end of file diff --git a/Java.gitignore b/Java.gitignore new file mode 100644 index 0000000000..46775e45bc --- /dev/null +++ b/Java.gitignore @@ -0,0 +1,3 @@ +*.class + + \ No newline at end of file diff --git a/JiangbinWu.md b/JiangbinWu.md new file mode 100644 index 0000000000..e1a905bf2d --- /dev/null +++ b/JiangbinWu.md @@ -0,0 +1,4 @@ +Thanks! +========= + +Thanks for your Git lessons. diff --git a/JoeZhouWenxuan.md b/JoeZhouWenxuan.md new file mode 100644 index 0000000000..58e2592d61 --- /dev/null +++ b/JoeZhouWenxuan.md @@ -0,0 +1,2 @@ +this is a test + diff --git a/JohnTsaiAndroid.txt b/JohnTsaiAndroid.txt new file mode 100644 index 0000000000..14ae176bd9 --- /dev/null +++ b/JohnTsaiAndroid.txt @@ -0,0 +1 @@ +Thank you,Mr Liao. diff --git a/KID-G-two.txt b/KID-G-two.txt new file mode 100644 index 0000000000..46c6009c81 --- /dev/null +++ b/KID-G-two.txt @@ -0,0 +1 @@ +hello michaelliao,I am a teacher for PHP,thank you for your help on git! diff --git a/KID-G.txt b/KID-G.txt new file mode 100644 index 0000000000..a042389697 --- /dev/null +++ b/KID-G.txt @@ -0,0 +1 @@ +hello world! diff --git a/Kandane.txt b/Kandane.txt new file mode 100644 index 0000000000..afb0a8fd80 --- /dev/null +++ b/Kandane.txt @@ -0,0 +1,9 @@ +快毕业找工作了,在复习的时候才知道有版本管理器,自己对着很古老的一本书 +从RCS开始看起的,看过CVS 和 SVN ,最后看的GIT。从网上搜到你的教程,之前 +有人说中文的GIT的教程不多,学起来不容易。我对着你的教程学到现在,感觉其 +实也不是很难,当然这也是你的教程写的水平比较高,比较生动的原因。在这里 +十分的感谢你,能够花费这么多的精力来写下这份教程。 +感觉GIT比较适合现在的我使用。当然我也没有发现大家说的CVS的问题。还是使 +用的深度不够。把这个体验完打算去试试开源中国假设的GIT托管网站,看看有什 +么不同。 +最后再次感谢你。 diff --git a/Kean.txt b/Kean.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Kevin--Wu.txt b/Kevin--Wu.txt new file mode 100644 index 0000000000..a0e9a7f568 --- /dev/null +++ b/Kevin--Wu.txt @@ -0,0 +1,4 @@ +Mr.liao: + Thank you for your awesome Git lessons.It helps me a lot in exploring this new world. + Kevin--Wu + 2015/2/10 diff --git a/Kevin.txt b/Kevin.txt new file mode 100644 index 0000000000..87f5edcdad --- /dev/null +++ b/Kevin.txt @@ -0,0 +1 @@ +Love you! teacher! \ No newline at end of file diff --git a/KiritoSai.md b/KiritoSai.md new file mode 100644 index 0000000000..25ba103099 --- /dev/null +++ b/KiritoSai.md @@ -0,0 +1,3 @@ +#the first pull request of KiritoSai +1. Thank you for the best git lesson i have ever seen. +2. This is my first pull request. \ No newline at end of file diff --git a/LYJ_LYJ@126.com b/LYJ_LYJ@126.com new file mode 100644 index 0000000000..dc36b02476 --- /dev/null +++ b/LYJ_LYJ@126.com @@ -0,0 +1 @@ +看了作者的博客,终于感觉对git有了一些基础理解了,作者提供了这么详细易懂的基础教程,小白再次表示深深的谢意。 diff --git a/LaCibeles.txt b/LaCibeles.txt new file mode 100644 index 0000000000..14e24d58c1 --- /dev/null +++ b/LaCibeles.txt @@ -0,0 +1,6 @@ +Michael: +I read ur guide for Git in English version about 3 months ago. I feel its the best guide for Git i've ever read before. This guide makes everything easy for beginners to enjoy Git. +So i just want say thank you to what all u've done and give out more excellent guides. +Good luck! +Yours +LaCibeles diff --git a/Lenhoon.txt b/Lenhoon.txt new file mode 100644 index 0000000000..c178845a77 --- /dev/null +++ b/Lenhoon.txt @@ -0,0 +1,3 @@ +Dear 廖大大: + 您好,用了不到三天的时间把这套Git教程学习完了。教程很好,之前一直很自卑,感觉自己什么都不会,连Git都不知道到底是个什么东西。在这三天中通过对Git的学习,增加了自信,虽然用的还不是很熟练,很多命令还要在查,但是通过这套教程地学习,不仅学会了Git的使用,而且加深了对shell的使用,对Vim的使用,在学习工程中,为了删除根目录下的一个隐藏文件,还误把根目录删了,这更加深了对Git学习地决心,以后项目都放到GitHub上:) + 之前在断断续续地看您地python的教程,之后也会继续加深对python的学习,总之,感谢您! diff --git a/Linyanyu.txt b/Linyanyu.txt new file mode 100644 index 0000000000..f2eb78997c --- /dev/null +++ b/Linyanyu.txt @@ -0,0 +1 @@ +thank you mr liao diff --git a/Luodinonesheng@gmail.com b/Luodinonesheng@gmail.com new file mode 100644 index 0000000000..8690d39f8d --- /dev/null +++ b/Luodinonesheng@gmail.com @@ -0,0 +1 @@ +i'm learning the git! git is very cool and strong!i like it!and i really want test how to pull request,so ,i hope teacher liao that you can take this file!thank you ! diff --git a/MyCourseOfGIt.txt b/MyCourseOfGIt.txt new file mode 100644 index 0000000000..2959c4d203 --- /dev/null +++ b/MyCourseOfGIt.txt @@ -0,0 +1 @@ +花了一周时间学习了git的使用,感谢博主的博文,给了我非常大的帮助 \ No newline at end of file diff --git a/MyUbuntuGitHub.txt b/MyUbuntuGitHub.txt new file mode 100644 index 0000000000..9b9825769a --- /dev/null +++ b/MyUbuntuGitHub.txt @@ -0,0 +1,7 @@ +-*- coding: utf-8 -*- + +Without doubt, this is the best articles I have ever read about GitHub. + +Thanks a lot, best wish. + +Kaka **_** diff --git a/NCRD.txt b/NCRD.txt new file mode 100644 index 0000000000..70513614ff --- /dev/null +++ b/NCRD.txt @@ -0,0 +1 @@ +This is from NCRD lab of Nanjing university in China. diff --git a/Nicall.txt b/Nicall.txt new file mode 100644 index 0000000000..2467057c77 --- /dev/null +++ b/Nicall.txt @@ -0,0 +1 @@ +Thanks Liao! \ No newline at end of file diff --git a/Nice-PLQ.txt b/Nice-PLQ.txt new file mode 100644 index 0000000000..8f91114b87 --- /dev/null +++ b/Nice-PLQ.txt @@ -0,0 +1 @@ +This is the first time that I have learn Git. \ No newline at end of file diff --git a/Notes_LearningGit.md b/Notes_LearningGit.md new file mode 100644 index 0000000000..eec28a2215 --- /dev/null +++ b/Notes_LearningGit.md @@ -0,0 +1,148 @@ +##Git 初步 +初始化一个Git仓库,使用`git init`命令。 + +添加文件到Git仓库,分两步: + +1. 使用命令`git add `,注意,可反复多次使用,添加多个文件; +2. 使用命令`git commit`,完成。 +通常使用 `git commit -m "something to comment"` +3. 注意,每次commit前都先要`add commit`,如果在commit前没有add,那么只会commit到之前add时候的内容 + +##Git查看 +* 要随时掌握工作区的状态,使用`git status`命令。 +* 如果`git status`告诉你有文件被修改过,用`git diff`可以查看修改内容。 +* 使用`git log`来查看git commit记录 +* 也可以使用`git log --pretty=oneline` 一行显示 + +##版本回退 +HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令: + +* `git reset --hard commit_id` 回退到id的版本 +* `git reset --hard HEAD^` 回退一个版本 +* `git reset --hard HEAD^^` 回退两个版本 +* `git reset --hard HEAD~100` 回退一百个版本 + +穿梭前,用`git log`可以查看提交历史,以便确定要回退到哪个版本。 +要重返未来,用`git reflog`查看命令历史,以便确定要回到未来的哪个版本。 + +##工作区与暂存区 +`git add`命令实际上就是把要提交的所有修改放到暂存区(Stage) + +![git add](/Users/Des/Documents/Coding/notes/image/git add.jpeg) +`git commit`就可以一次性把暂存区的所有修改提交到分支。 + +![git commit](/Users/Des/Documents/Coding/notes/image/git commit.jpeg) + +##撤销修改 撤销删除 +删除文件 使用 rm file,但是如果想要版本库也删除的话 需要使用 `git rm file` + +1. 当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令`git checkout -- file`。 git checkout其实是用版本库里的版本替换工作区的版本,如果在无论工作区是修改还是删除,比如不小心删掉文件了,使用`git checkout --file`都可以“一键还原”,将这个工作区的文件用版本库里边的恢复。 + +2. 当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,即已经进行了`add`操作,想丢弃修改,分两步,第一步用命令`git reset HEAD file`,就回到了场景1,第二步按场景1操作。 + +3. 已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + +##远程连接 +####从本地拷贝到远程库 +cd到要拷贝的git的文件夹 + +1. 要关联一个远程库,使用命令 `git remote add origin git@server-name:path/repo-name.git`; +2. 比如 `git remote add origin git@github.com:rwang23/xx.git` + +2. 关联后,使用命令`git push -u origin master`第一次推送master分支的所有内容,如果不是master分支,换名字就可以; + +3. 此后,每次本地提交后,只要有必要,就可以使用命令`git push origin master`推送最新修改; + +分布式版本系统的最大好处之一是在本地工作完全不需要考虑远程库的存在,也就是有没有联网都可以正常工作,而SVN在没有联网的时候是拒绝干活的!当有网络的时候,再把本地提交推送一下就完成了同步,真是太方便了! + +####从远程库克隆到本地 +进入要克隆到的文件夹, +`git clone git@github.com:michaelliao/gitskills.git` +Git支持多种协议,包括https,但通过ssh支持的原生git协议速度最快。 + +##分支管理 +Git鼓励大量使用分支: + +* 查看分支:`git branch` +* 创建分支:`git branch ` +* 切换分支:`git checkout ` +* 创建+切换分支:`git checkout -b ` +* 合并某分支到当前分支:`git merge ` +* 删除分支:`git branch -d ` +* 开发一个新feature,最好新建一个分支;如果要丢弃一个没有被合并过的分支,可以通过`git branch -D `强行删除。 + +合并分支的时候如果出现冲突,那么将会出现冲突提醒 +并在当前分支上出现: + + <<<<<<< HEAD + Creating a new branch is quick & simple. + ======= + Creating a new branch is quick AND simple. + >>>>>>> feature1 +修改好后再次提交就可以了 +同时 可以使用 git log 或者git log --graph指令来查看分支与分支合并情况 + +通常情况下使用合并分支Git会自动使用`Fast forward`模式,但是这种情况下删除分支后,会丢失分支信息, +这个时候我们可以使用--no-ff方式下的`git merge`,它会提交一个新的commit +`git merge --no-ff -m "merge with no-ff" dev` + + +###分支策略 + +* master分支应该是非常稳定的,也就是仅用来发布新版本的 +* 一般干活都在dev分支上的,一般来说dev分支是不稳定的,比如到了某个时候才合并到master上边,在master上边发布新版本 +![git branch merge](/Users/Des/Documents/Coding/notes/image/git branch&merge.png + +####Bug出现的修复 + +* 当正在新的branch进行工作时,想要修复原来的branch比如master的bug,这个时候就想切换到master。 + +* 但是此时由于branch还没完成不能提交,所以我们可以使用`git stash`来储存当前工作现场 + +* 然后就可以切换到要修改Bug的branch然后创建bug新分支再用原分支合并,再切换到刚才的新brach工作 + +如何储存工作现场? + +1. 使用`git stash`来储存当前工作现场 + +2. 可以使用`git stash list`来查看当前工作现场 + +3. 工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: + +* 一是用`git stash apply`恢复,但是恢复后,stash内容并不删除,你需要用`git stash drop`来删除; + +* 另一种方式是用`git stash pop`,恢复的同时把stash内容也删了: + +##多人协作 +查看远程库信息,使用git remote -v; + +多人协作的工作模式通常是这样: + +1. 首先,可以试图用git push origin branch-name推送自己的修改; + +2. 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +3. 如果合并有冲突,则解决冲突,并在本地提交; + +4. 没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +5. 如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单。 + +##标签管理 + +###创建标签 +* 命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; +* git tag commit_id 在该commit_id上打上标签 +* git tag -a -m "blablabla..." commit_id可以指定标签信息; +* git tag -s -m "blablabla..."可以用PGP签名标签; +* 命令git tag可以查看所有标签。 + +###修改标签 +因为创建的标签都只存储在本地,不会自动推送到远程。所以,打错的标签可以在本地安全删除。 + +* 命令`git push origin tagname`可以推送一个本地标签; +* 命令`git push origin --tags`可以推送全部未推送过的本地标签; +* 命令`git tag -d tagname`可以删除一个本地标签; +* 命令`git push origin :refs/tags/`可以删除一个远程标签。 \ No newline at end of file diff --git a/PanYutong.txt b/PanYutong.txt new file mode 100644 index 0000000000..50d45631f4 --- /dev/null +++ b/PanYutong.txt @@ -0,0 +1,2 @@ +非常感谢廖雪峰写的这个github教程,帮助我从0开始迅速上手使用github +P.S.作者太可爱了。。。 diff --git a/PeterAnderson.txt b/PeterAnderson.txt new file mode 100644 index 0000000000..0a3c481c2e --- /dev/null +++ b/PeterAnderson.txt @@ -0,0 +1 @@ +Thanks a lot, Xuefeng Liao, your tutorial is very good for the little birds! \ No newline at end of file diff --git a/PretendDemo.txt b/PretendDemo.txt new file mode 100644 index 0000000000..655284924b --- /dev/null +++ b/PretendDemo.txt @@ -0,0 +1 @@ +thanks your guide! diff --git a/README.md b/README.md new file mode 100644 index 0000000000..32486a95a6 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +gitskills +========= diff --git a/Rockyzsu_Git_Study b/Rockyzsu_Git_Study new file mode 100644 index 0000000000..bf1d388af2 --- /dev/null +++ b/Rockyzsu_Git_Study @@ -0,0 +1,6 @@ +Hi I am Rocky, now working at NVIDIA, as SWQA. +This blog is very useful for me to learn git one step by step and build up my git repository in github. I need to send my great appriciation to YOU ! +Now i am going to forward this blog to my friends , big alias to learn this course. + +Best regards, +Rocky Chen diff --git a/RoseWsp.txt b/RoseWsp.txt new file mode 100644 index 0000000000..eb5a18ce57 --- /dev/null +++ b/RoseWsp.txt @@ -0,0 +1,211 @@ + +//Sorry i copy from others , for Test + +Skip to content +This repository +Explore +Gist +Blog +Help +@RoseWsp RoseWsp + + Unwatch 1 + Star 0 + Fork 840 +RoseWsp/learngit +forked from michaelliao/learngit + branch: master learngit/your-github-whatswhat.txt +@whatswhatwhatswhat on 8 Nov 2014 try fork and pull request +1 contributor +RawBlameHistory 190 lines (126 sloc) 8.403 kB + + + + + +$ git init 初始化一个Git仓库 + +添加文件到Git仓库,分两步: +$ git add +$ git commit -m "....." + +$ git status + +$ git diff #比较工作区和暂存区文件差异 (Working Directory工作区(add操作前) 和 stage暂存区(add操作后) 的区别) +$ git diff HEAD -- 查看工作区和版本库里面最新版本的区别(Working Directory工作区(add操作前) 和 Repository版本库(commit操作后) 的区别) + + +版本回退: +$ git reset --hard +$ git reset --hard HEAD^ +首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交3628164...882e1e0(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。 + + +$ git log 查看提交历史 +$ git log --pretty=oneline + +$ git reflog 查看命令历史 + + + * +HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 + * +穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 + * +要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本 + + + +撤销修改: +$ git checkout -- readme.txt 把readme.txt文件在工作区的修改全部撤销 丢弃工作区的修改 +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +总之,就是让这个文件回到最近一次git commit或git add时的状态。 + +$ git reset HEAD file 把暂存区的修改撤销掉(unstage),重新放回工作区 + + +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + +远程仓库 +$ git push -u origin master +$ git push origin master + + +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +从远程库克隆: +$ git clone git@github.com:whatswhat/gitskills.git 后面是仓库的地址 ssh(速度快) +$ git clone https://github.com/whatswhat/gitskills.git 后面是仓库的地址 http + +分支管理 +创建与合并分支 + + +查看分支:git branch +创建分支:git branch +切换分支:git checkout +创建+切换分支:git checkout -b +合并某分支到当前分支:git merge +删除分支:git branch -d +解决冲突、分支管理策略 +用git log --graph命令可以看到分支合并图 +$ git log --graph --pretty=oneline --abbrev-commit + + + +通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。--no-ff方式的git merge: 准备合并dev分支,请注意--no-ff参数,表示禁用Fast forward: +$ git merge --no-ff -m "merge with no-ff" dev + + +Bug分支 +Git还提供了一个stash功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作: +$ git stash +$ git stash list + + +工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +$ git stash apply + +$ git stash pop + + + +你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,用命令: + +$ git stash apply stash@{0} + + + +小结 +修复bug时,我们会通过创建新的bug分支进行修复,然后合并,最后删除; +当手头工作没有完成时,先把工作现场git stash一下,然后去修复bug,修复后,再git stash pop,回到工作现场。 + +Feature分支 + +开发一个新feature,最好新建一个分支; +如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 + +多人协作 + + +当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应起来了,并且,远程仓库的默认名称是origin。 +$ git remote 查看远程库的信息 +$ git remote -v 显示更详细的信息(显示可以抓取fetch和推送push的origin的地址) + +推送分支 +推送分支,就是把该分支上的所有本地提交推送到远程库。推送时,要指定本地分支,这样,Git就会把该分支推送到远程库对应的远程分支上: +$ git push origin master +如果要推送其他分支,比如dev,就改成: +$ git push origin dev + +并不是一定要把本地分支往远程推送,那么,哪些分支需要推送,哪些不需要呢? + + * +master分支是主分支,因此要时刻与远程同步; + * +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + * +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + * +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + +总之,就是在Git中,分支完全可以在本地自己藏着玩,是否推送,视你的心情而定! + +抓取分支 +$ git checkout -b dev origin/dev 创建远程origin的dev分支到本地 +$ git branch --set-upstream dev origin/dev 设置本地dev分支与远程origin/dev分支的链接 +$ git pull 把最新的提交从远程origin/dev抓下来 + + +多人协作的工作模式通常是这样: + + 1. +首先,可以试图用git push origin branch-name推送自己的修改; + 2. +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + 3. +如果合并有冲突,则解决冲突,并在本地提交; + 4. +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + + +小结 + + * +查看远程库信息,使用git remote -v; + * +本地新建的分支如果不推送到远程,对其他人就是不可见的; + * +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + * +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + * +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + * +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + +标签管理 +创建标签 +$ git tag 新建一个标签(需先切换到要打标签的分支上)(默认为HEAD,也可以指定一个commit id) +$ git tag -a -m "…" 指定标签信息 +$ git tag -s -m “…" 用PGP签名标签(如果报错,请参考GnuPG帮助文档配置Key。) +$ git tag 查看所有标签 +$ git show 查看标签信息 + +操作标签 +$ git tag -d 删除一个本地标签 +$ git push origin 推送一个本地标签 +$ git push origin --tags 一次性推送全部未推送到远程的本地标签 +$ git push origin :refs/tags/ (从远程删除)删除一个远程标签(需先从本地删除即先执行git tag -d 命令) +Status API Training Shop Blog About +© 2015 GitHub, Inc. Terms Privacy Security Contact diff --git a/Rowandjj.txt b/Rowandjj.txt new file mode 100644 index 0000000000..434c723ef2 --- /dev/null +++ b/Rowandjj.txt @@ -0,0 +1,3 @@ +我觉得这是我看到过的最好的Git教程,没有之一!!! +感谢廖老师! +希望能够推出越来越多的精品教程! \ No newline at end of file diff --git a/ScienceXChina.txt b/ScienceXChina.txt new file mode 100644 index 0000000000..bebc61134a --- /dev/null +++ b/ScienceXChina.txt @@ -0,0 +1 @@ +Thank you very much.Your are my teacher. diff --git a/SimbaQ.txt b/SimbaQ.txt new file mode 100644 index 0000000000..d03919aa5d --- /dev/null +++ b/SimbaQ.txt @@ -0,0 +1,4 @@ +多谢您,廖老师! +第一次看一个专业教程这么上瘾!学着学着就欲罢不能了,一口气把整个教程看完了。 +准备看完您的这个git教程后,再学习一下您的Python教程。 +多谢! diff --git a/SmallHJ.txt b/SmallHJ.txt new file mode 100644 index 0000000000..2aef5541e3 --- /dev/null +++ b/SmallHJ.txt @@ -0,0 +1 @@ +Thank you very much! \ No newline at end of file diff --git a/SomeSuggestions b/SomeSuggestions new file mode 100644 index 0000000000..9df30065be --- /dev/null +++ b/SomeSuggestions @@ -0,0 +1,9 @@ +Git is a good tool to control the version +Mr.Liao is a Good Teacher + +Best wishes for you +------ +Mr.Yang + +some suggestion: +可以把git学习的文档放到gitHub上,有些命令或者更简洁的做法,我们可以补充进去啊。 diff --git a/StarLee.txt b/StarLee.txt new file mode 100644 index 0000000000..b2496da2cc --- /dev/null +++ b/StarLee.txt @@ -0,0 +1,2 @@ +git is great +---lxx diff --git a/StromNote.txt b/StromNote.txt new file mode 100644 index 0000000000..18e9b58994 --- /dev/null +++ b/StromNote.txt @@ -0,0 +1,335 @@ +摘自廖雪峰的git教程(Thanks Liao) +=============================================================================== +创建版本库: + 版本库又名仓库repository,其实就是一个可以被git管理的目录 + $ mkdir foo 选择一个合适的地方建一个文件夹 + $ cd foo 进入这个文件夹 + $ git init 通过git init命令把当前目录建立成为git仓库 + 建好之后这个目录下回多一个.git目录,这个目录就是git用来跟踪管理版本库的 + 其实也可以使用非控文件夹做git仓库 + + 把文件添加进仓库 + 在foo目录下新建一个readme.txt + $ git add readme.txt 把文件添加到仓库 + $ git commit -m "..." 把文件提交到仓库,并添加说明 + 可以多次add再统一commit + +------------------------------------------------------------------------------- +时光穿梭: + 版本回退: + 使用git statue命令能实时掌握当前git仓库的状态 + $ git statue + 如果你想看看文件被改动了哪些内容,就需要使用git diff命令 + $ git diff + 这里的git diff其实是比较的已经add的和未add的文件之间的差别 + + git会给我们的工作保存快照,这个快照就是commit,所以我们可以随时回到过去 + 使用git log命令来查看历史记录 + $ git log + 使用--pretty=oneline参数可以减少log的输出,使他的每个记录只输出一行 + $ git log --pretty=oneline + 每条记录都会有一个commit id,这条id就表示了这条记录 + git用HEAD表示当前版本,HEAD^表示上一个版本,以此类推HEAD^^...HEAD~100 + 然后就可以使用如下命令回到过去了 + $ git reset --hard HEAD^ + $ git reset --hard 这里commit id只打前几位能区分开来就好 + 使用了git reset命令,HEAD就指向指定的版本,再使用log命令将只能获得当前 + HEAD版本之前的版本 + 所以我们要使用下面的命令,git记录了我们的每次操作 + $ git reflog + 使用这个命令找到比当前版本新的版本的commit id就可以reset回去了 + 总之:log命令可以查看提交历史,reflog可以查看命令历史 + + 工作区和暂存区: + 工作区(work directory)就是我们在电脑里能看到的目录,比复foo文件夹 + 版本库(repository)工作区有一个隐藏目录.git,它不属于工作区,而是git的版本库 + git的版本库里存在了很多东西,其中最重要的就是: + 称为stage(或者叫index)的暂存区 + git为我们创建的第一个分支master + 指向master的指针HEAD + git add就是把文件添加到暂存区 + git commit就是把暂存区文件提交到当前分支 + 因为只有默认创建的master分支,所以commit就是往master分支提交 + 因为每次commit的都是暂存区的内容,所以没有被add的内容不会被commit + 使用如下命令可以比较工作区文件和暂存区文件的异同 + $ git diff -- file + 撤销修改: + 使用如下命令可以撤销工作区的修改 + $ git checkout -- file + 这条命令实际上是把工作区的文件恢复到暂存区的状态 + 即使工作区的状态恢复到上次add,或commit时候的状态 + + 使用下面的命令可以撤销add到暂存区的操作 + $ git reset HEAD file + 这条命令是在提交到暂存区之后又后悔了,使用它使文件恢复到版本库的状态 + 即使工作区的状态恢复到上次commit时候的状态 + 删除文件: + 通常在工作区中删除文件,直接rm即可 + 这时在查看git状态时会提示你工作区中哪些文件被删除了 + 这时,使用如下命令删除版本库中的对应文件 + $ git rm foo.txt + $ git commit + 同样可以使用如下命令,找回该文件 + $ git checkout -- foo.txt + +------------------------------------------------------------------------------- +远程仓库: + git的远程仓库,除了可以自己搭建之外,还可以使用github,本机git和github通信 + 是通过ssh协议加密的,所以需要如下设置(可选): + 1.创建ssh key,如果用户主目录下有.ssh文件夹,且其内有id_rsa和id_rsa.pub + 两个文件可以跳过第一步了,如果没有打开shell,创建ssh key: + $ ssh-keygen -t rsa -C "your_email@example.com" + 2.一切顺利就能创建成功,私钥是id_rsa,公钥是id_rsa..pub,登录github,进入 + Account setting,ssh key页面,然后add ssh key,填上任意title,在key文本里 + 粘贴id_rsa.pub内容,点击啊add key即可完成。 + + 添加远程仓库: + 添加远程仓库先在github创建repository,然后可以克隆到本地或关联本地仓库 + 在git中远程仓库默认叫做origin + 关联本地仓库: + 回到本地的仓库,运行一下命令 + $ git remote add origin git @github.com:somebody/foo.git + 把本地仓库内容推送到远程仓库 + $ git push -u origin master + 这条命令实际上是吧当前分支master推送到远程 + 因为远程库是空的,所以这次推送加上-u选项,git不但把本地master分支 + 推送到远程的master分支,还把两者关联起来,以后的推送拉去就能简化命令 + 以后的推送都可以使用下面的命令来实现 + $ git push origin master + 从远程库中克隆: + 要是从头开发的话,可以先在github创建repository,然后在克隆到本地 + 使用如下命令来克隆到本地 + $ git clone git@github.com:somebody/foo.git + 其实git给出的地址不止一个,还可以使用https://github.com/somebody/foo.git + 其实git是支持多种协议的,默认的git://使用ssh,但也可以使用https等其他协议 + +------------------------------------------------------------------------------- +分支管理: + git无论是创建,切换和删除分支,都只需要不到1秒,无论一个文件还是一万个文件 + 创建与合并分支: + 一开始master分支是一条线,git用master指向最新的提交,再用HEAD指向master,就 + 能确定当前分支,以及当前分支的提交点,每次提交master都会向前移动一小步, + 当我们创建新的分支dev时,git就创建一个新的指针,指向与master相同的指针 + ,再把HEAD指向dev,从现在开始,对工作区的修改和提交就是针对dev分支了,在 + dev上的工作完成后,就可以把dev合并到master上,其实就是把master指针指向d + ev当前的提交,这时就可以把dev分支删除了,由此可见,git的分支操作很快 + + 使用如下命令创建并切换到dev分支,-b就表示创建并切换 + $ git checkout -b dev + 这条命令相当于下面两条 + $ git branch dev + $ git checkout dev + 然后使用git branch查看当前分支,这条命令会列出所有分支,当前分支标有*号 + $ git branch + 在dev上的工作和master相同,这时如果想切换会master,使用如下命令 + $ git checkout master + 现在把dev分支上的内容合并到master,使用如下命令 + $ git merge dev + 注意这个命令用于将指定分支合并到当前分支 + 合并时候就可以删除dev分支了,使用如下命令 + $ git branch -d dev + git鼓励我们用分支来完成任务,这样不会托慢速度而且更安全 + + 解决冲突: + 分支合并也不总是一帆风顺的,有时候master分支和dev分支都在进行开发,两个分支 + 都进行新的commit,而且提交了相同的文件,但是内容不同,这时就不能快速合并 + 需要手动修改冲突文件,使用git statue可以查看冲突文件,修改后在提交就好了 + 使用如下命令能查看分支合并图 + $ git log --graph + $ git log --graph --pretty=oneline --abbrev-commit + + 分支管理策略: + 通常合并分支时,如果可能,git会使用Fast forward模式,但是这种模式下删除分支后, + 会丢失分支信息,如果强制使用Fast forward模式,git会在merge时生成一个 + commit来保存信息 + + 策略: + 1.实际开发中,master分支应该是非常稳定的,仅仅用来发布新版本,平时不 + 能再上面干活 + 2.干活都在dev分支上,dev分支是不稳定的,仅当发布新版本时候把dev分支合并到 + master分支上,然后在master分支上发布1.0版本什么的 + 3.每个小伙伴都在dev分支上干活,每个人都有自己的分支,时不时地往dev分 + 支上合并就好了 + + git分支十分强大,在团队开发中应该充分利用 + 在合并分支时候,加上--no-ff参数就可以使用普通模式合并,合并后的历史有分支, + 能看出曾进做过的合并,而Fast forward合并就看不出曾进做过的合并 + + --no-ff合并: + 普通模式合并,no-ff表示禁用Fast forward + 使用如下命令进行no-ff合并,因为合并生成一个commit,所以加-m参数加说明 + $ git merge --no-ff -m "merge with no-ff" + + bug分支: + git分支管理非常强大,每个bug都可以使用临时分支来解决,合并后就可以删除了 + 一个很常见的bug修复流程: + 首先使用git stash将当前工作区储藏起来,以备日后恢复工作 + $ git stash + 这时又是干净的工作区了,若要在master上修复bug,就在master上建bug分支 + $ git checkout master 切换到master分支 + $ git checkout -b issue-101 创建并切换到bug分支issue-101 + 修复bug完成后,切换到master分支,并完成合并,然后删除bug分支 + $ git checkout mater 切换到master分支 + $ git merge --no-ff issue-101 -m "merge bug fix 101" 合并分支 + $ git branch -d issue-101 删粗bug修复分支 + 切换会dev分支 + $ git checkout dev + 要恢复stash起来的工作区,首先使用下面的命令查看stash list + $ git stash list + 1.要恢复工作区,方法一 + $ git stash apply stash@{0} 恢复stash@{0}存储的工作区 + $ git stash drop stash@{0} 删除stash{0} + 2.要恢复工作区,方法二 + $ git stash pop 恢复工作区,并删除stash + + feature分支: + 开发时,有时候希望添加一些新功能,但我们不希望实验性的代码把主分支弄坏 + 可以创建feature分支,在上面开发,完成后再合并,删粗 + 首先新建一个feature分支 + $ git checkout -b feature-newfun 新建并切换到feature分支 + 开发完成后回到dev分支,准备合并 + $ git checkout dev + 1.如果一切顺利就可以合并并删除feature分支了 + $ git merge --no-ff feature-newfun -m "add new fun" + $ git branch -d feature-newfun + 2.如果这时情况有变,要取消新功能,我们就需要销毁feature分支 + $ git branch -d feature-newfun + 这时会销毁失败,需要强制销毁 + $ git branch -D feature-newfun + 至此删除feature分支完成 + + 多人协作: + 当我们从远程仓库中克隆的时候,git把本地master分支和远程的master分支关联了, + 并且远程仓库的默认名称是origin + 要查看远程仓库,使用如下命令 + $ git remote + 或者使用-v选项显示更详细的信息 + $ git remote -v + 上面会显示可以抓取和推送的git地址,如果没有推送权限将看不到push地址 + + 推送分支: + 推送分支时候,要指定本地分支,这样把该分支推送到远程仓库对应的分支上 + $ git push orgin master + 如果要退送其他分支,比如dev分支 + $ git push orgin dev + 但是,并不一定要把本地分支都推送到远程分支上, + master是主分支,因此要时时刻刻与远程分支同步 + dev是开发分支,团队成员都要在上面工作,因此也要时刻与远程分支同步 + bug分支只用在本地修复bug,没必要推送,除非老板要看你每周修复几个bug + feature分支是否推送,取决于你是否和小伙伴合作在上面开发 + + 总之,分支是否往远程推送,取决于自己,完全可以在本地自己藏着玩 + 通常要合作在上面开发的分支都要推送到远程仓库 + + 抓取分支: + 使用下面的命令从远程库抓取,或者克隆本地库 + $ git clone repository + 从远程库中克隆下来的只有master分支,现在要在dev分支上开发,就要在本地 + 创建远程organ的dev分支 + $ git branch -b dev orgin/dev + 这时你的小伙伴就可以在他本地push到远程了 + 如果你的小伙伴push是碰巧你也push了相同文件呢,这时就会产生冲突 + 这时推送就会失败,这时就要把远程库的代码抓下来解决冲突 + $ git pull + 可能pull失败,因为没有本地dev分支没有和远程dev分支关联 + 这时使用下面的代码来关联 + $ git branch --set-upstream branch-name orgin/branch-name + 来下来之后,常常会有合并冲突,需要手动解决 + 解决后再push就好了 + + 多人合作的工作模式常常是这样的: + 首先可以使用下面的命令推送自己的修改 + $ git push orgin branch-name + 如果推送失败是因为远程分支比你本地的新,使用pull合并 + $ git pull + 如果合并有冲突,需要解决冲突,在本地提交 + 没有冲突或者解决掉冲突后就可以推送了 + $ git push orgin branch-name + + 如果git提示"no tracking information",则说明本地分支没有和远程库的分支 + 关联,使用下面的命令来关联 + $ git branch --set-upstream branch-name orgin/branch-name + +------------------------------------------------------------------------------- +标签管理: + 发布一个版本时,我么常常现在版本库中打一个标签,这样就唯一确定了打标签时候的 + 版本,将来无论什么时候,随时都可以取出打标签的版本,其实就是一个版本快照 + + git的标签也是一个指针,和分支很像,不同的是,分支可以移动,而标签不能移动 + + 创建标签: + 首先切换到要打标签的版本 + $ git checkout master + 然后使用如下的命令打标签 + $ git tag v1.0 + 可以使用如下的命令查看所有标签 + $ git tag + 打标签默认是打在最近的commit上的,如果要给历史版本打标签 + 就要先找到历史的commit id再给它大上 + $ git log --pretty=oneline --abbrev-commit + $ git tag v0.9 633834 + 注意标签不是按照时间排序,而是按照字母排序的 + 使用git tag 查看标签信息 + 还可以创建带说明的标签,使用-a指定标签名,-m指定说明 + $ git tag -a v0.1 -m "this is a tag" 632345 + 还可可以使用-s用私钥签名一个标签 + $ git tag -s v0.2 -m "signed version 0.2 released" f234b3 + 签名使用GPG签名,所以必须先安装了GunPG,并且有gpg密钥对 + + 操作标签: + 删除标签: + $ git tag -d v0.1 + 推送标签到远程 + $ git push origin + 或者可以一次性推送所有本地标签 + $ git push origin --tags + 删除远程标签,要先删本地的,再删远程的 + $ git tag -d v0.1 + $ git push origin :refs/tags/v0.1 + +------------------------------------------------------------------------------- +使用GitHub: + github不仅仅是一个提供git远程仓库的网站,也是一个开源协作社区 + 通过github,我们既可以参与别人的开源项目,别人也可以参与我们的开源项目 + + 在github上可以fork别人的项目到自己的帐号下,再从自己的帐号下clone + 自己的开发要往自己的远程库推送,如果我们改一个bug什么的,可以在github + 上发起pull request,然后就看别人是否接受了 +------------------------------------------------------------------------------- +自定义git: + git有很多配置选项 + 如之前见到的 + $ git config --global user.name "xxx" + $ git config --global user.email "xxx@example.com" + $ git config --global color.ui true + + 忽略特殊文件: + 我们开发时常常需要把一些不想被git管理的文件添加到git管理的文件夹 + 比如java编译厚的.class文件 + 这时在git根目录新建.gitignore文件在里面写忽略规则即可 + https://github.com/github/gitignore这个网站已经为我们提供了各种情况 + 的忽略规则,我们只要适当组合即可 + 配置别名: + git也有alias就像linux的alias,很好用,特别是不能补全命令的windows上 + git config --global alias.st statue + 一个有趣的配置: + git config --global alias.lg "log --color --graph + --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) + %C(bold blue)<%an>%Creset' --abbrev-commit" + 配置git的时候,--global是对当前用户起作用的,不加就是对当前库起作用 + 每个仓库的git配置文件都放在.git/config中 + 每个用户的git配置文件都放在用户主目录的.gitconfig中 + 搭建git服务器: + 1.在linux上搭建git服务器: + $ sudo apt-get install git (sudo yum install git) + $ sudo adduser git + 2.创建证书登录,收集所有需要登录用户的公钥,即id_rsa.pub + 放入/home/git/.ssh/authorized_keys文件里,一行一个 + 3.初始化git仓库,切换到自己指定的git目录执行 + $ sudo git init -bare sample.git 服务器专用的初始化方式 + 4.把git目录owner改为git + $ sudo chown git:git sample.git + 5.禁用git用户shell登录 + 在/etc/passwd文件中把git的登录运行文件改为/usr/bin/git-shell + 这样git服务器就设置好了,可以在自己的电脑上clone了 + $ git clone git@server:/srv/sample.git diff --git a/Syt.txt b/Syt.txt new file mode 100644 index 0000000000..9157ed51a4 --- /dev/null +++ b/Syt.txt @@ -0,0 +1 @@ +感谢廖大神的教程,浅显易懂,写的很好,赞! diff --git a/TEST b/TEST new file mode 100644 index 0000000000..d8fd44a4f3 --- /dev/null +++ b/TEST @@ -0,0 +1 @@ +Test for git diff --git a/Thanks to michaelliao b/Thanks to michaelliao new file mode 100644 index 0000000000..a542c304b7 --- /dev/null +++ b/Thanks to michaelliao @@ -0,0 +1,10 @@ +### Thanks to michaelliao +第一次学习廖学峰老师的教程是在廖学峰的官方网站,现在改版了。 + +去年学习Python,看了廖写的Python教程,受益匪浅。之后又看了他的Git教程。 + +十分感谢老师~让我这个Python/Git小白成长了不少,那时候也摸索着学Linux。是michaelliao的教学资源让我感觉到:咦,这个东西学着挺有意思的呢。 + +看到这么多commit,我也借助这个平台向廖学峰老师说声感谢啦。我关注你的微博,看到你经常跑步一跑就是十公里,佩服佩服啊。我也是跑步爱好者,不仅在专业技能上向你看齐,生活态度上也向你看齐。 + +Anyway,我也要加油!早日找到满意的工作,向IT大牛们积极靠拢! diff --git a/Thanks+1024.txt b/Thanks+1024.txt new file mode 100644 index 0000000000..e5a94c5ab5 --- /dev/null +++ b/Thanks+1024.txt @@ -0,0 +1,2 @@ +Thanks for your share! + your fans \ No newline at end of file diff --git a/ThanksForHalu126.txt b/ThanksForHalu126.txt new file mode 100644 index 0000000000..c87c211be9 --- /dev/null +++ b/ThanksForHalu126.txt @@ -0,0 +1,3 @@ +谢谢你给我的爱,让我入门了Git。 +halu126 +20141023 diff --git a/Thanks_from_Hennrik.txt b/Thanks_from_Hennrik.txt new file mode 100644 index 0000000000..806e97bcba --- /dev/null +++ b/Thanks_from_Hennrik.txt @@ -0,0 +1,9 @@ +Time:21:36 2015/5/1 +Location: Stockholm,Sweden + +Hi Liao, +Thank you for sharing your learning notes of Git, which help me a lot. I hope there will be a lot of excellent blogs from you,and I will so excited to explore them. + +Best regards, + +Hennrik \ No newline at end of file diff --git a/Thx.txt b/Thx.txt new file mode 100644 index 0000000000..57a1a0b41d --- /dev/null +++ b/Thx.txt @@ -0,0 +1 @@ +Thanks for sharing! diff --git a/TianYongwei.txt b/TianYongwei.txt new file mode 100644 index 0000000000..a88b8bdc6f --- /dev/null +++ b/TianYongwei.txt @@ -0,0 +1,4 @@ +hello, MR Liao. +Thanks for your git tutorial, I got a lot from it. +Thanks a lot! +--TianYongwei \ No newline at end of file diff --git a/TireTestFileTwo b/TireTestFileTwo new file mode 100644 index 0000000000..22f21d10f5 --- /dev/null +++ b/TireTestFileTwo @@ -0,0 +1 @@ +test file two diff --git a/Tjuly.txt b/Tjuly.txt new file mode 100644 index 0000000000..ee4630f16e --- /dev/null +++ b/Tjuly.txt @@ -0,0 +1 @@ +Thans to Teacher-lao, it's a good doc for our fresh-men \ No newline at end of file diff --git a/TomatoFish.txt b/TomatoFish.txt new file mode 100644 index 0000000000..82eb77880c --- /dev/null +++ b/TomatoFish.txt @@ -0,0 +1 @@ +Thank you very much! diff --git a/TomorOoO.txt b/TomorOoO.txt new file mode 100644 index 0000000000..6856f44a79 --- /dev/null +++ b/TomorOoO.txt @@ -0,0 +1 @@ +I have learned a lot,thank you!!! \ No newline at end of file diff --git a/VonAlex.txt b/VonAlex.txt new file mode 100644 index 0000000000..2b19040432 --- /dev/null +++ b/VonAlex.txt @@ -0,0 +1 @@ +Thank you! diff --git a/WhaleChenTest.txt b/WhaleChenTest.txt new file mode 100644 index 0000000000..93d667c6bf --- /dev/null +++ b/WhaleChenTest.txt @@ -0,0 +1,4 @@ +Hi, Mr. Liao + 3x for providing such a good course on line! + Bless! +Whale Chen \ No newline at end of file diff --git a/WonderdchNote.txt b/WonderdchNote.txt new file mode 100644 index 0000000000..4158c55fa4 --- /dev/null +++ b/WonderdchNote.txt @@ -0,0 +1,175 @@ +常用命令 + + +Git 配置 + git config --global +初始化Git + git init +添加文件到GIt仓库 + 添加: git add dir/files example:git add Readme.txt + 提交: git commit -m "commit instruction(本次提交的说明)" +查看仓库当前状态 + git status +查看上一次修改 + git diff +版本回退 + 查看提交日志: git log / git log --pretty=oneline + 版本回退: git reset --hard commit_id git reset --hard HEAD(HEAD当前版本,HEAD^上个版本,HEAD~100上一百个版本) + 重返未来: git reflog 查看命令历史,然后在其中确定commit_id +撤销修改 + 撤销工作区修改: git checkout -- file example: git checkout -- Readme.txt + 撤销暂存区修改: git reset HEAD file 然后 git checkout -- file +删除文件 + 删除本地文件: rm file 然后通过 git status 可以查看删除记录 + 撤销删除本地文件: git checkout -- file + 从git 库删除: git rm file 然后 git commit +同步 + + +上传 + 要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; + +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +下载 + 第一次通过Clone + git clone git@github.com:michaelliao/gitskills.git + git clone git@github.com:UserName/FolderName.git + 平时直接用Sync + +分支操作 + +Git鼓励大量使用分支: + +查看分支:git branch + +创建分支:git branch + +切换分支:git checkout + +创建+切换分支:git checkout -b + +合并某分支到当前分支:git merge + +删除分支:git branch -d + + + +分支策略 + +在实际开发中,我们应该按照几个基本原则进行分支管理: + +首先,master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活; + +那在哪干活呢?干活都在dev分支上,也就是说,dev分支是不稳定的,到某个时候,比如1.0版本发布时,再把dev分支合并到master上,在master分支发布1.0版本; + +你和你的小伙伴们每个人都在dev分支上干活,每个人都有自己的分支,时不时地往dev分支上合并就可以了。 + +所以,团队合作的分支看起来就像这样: + + + +小结: +Git分支十分强大,在团队开发中应该充分应用。 + +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + + +来源: + +其它分支 + +BUG 分支 + 修复bug时,可以另外建立一个bug分支,修改完后切换回master并合并分支,删除bug分支 + 去修复bug前,你要保存当前工作区,通过git stash 修复完成后返回工作区(git stash apply、git stash drop、)git stash pop +Feature分支 + 当为系统添加新功能时可以建立一个Feature分支 + + +多人协作 + + +git remote 查看远程库的信息 + +git remote -v显示更详细的信息 + +git push origin master将本地所有提交推送到远程库的master分支上 + + git push origin dev推送到远程库的dev分支上 + + + + +master分支是主分支,因此要时刻与远程同步; + +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + + + +多人协作的工作模式通常是这样: + +首先,可以试图用git push origin branch-name推送自己的修改; + +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +如果合并有冲突,则解决冲突,并在本地提交; + +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单。 + + +小结 +查看远程库信息,使用git remote -v; + +本地新建的分支如果不推送到远程,对其他人就是不可见的; + +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + + + + + +标签操作 + + + +发布一个版本时,我们通常先在版本库中打一个标签,这样,就唯一确定了打标签时刻的版本。将来无论什么时候,取某个标签的版本,就是把那个打标签的时刻的历史版本取出来。所以,标签也是版本库的一个快照。 + +Git的标签虽然是版本库的快照,但其实它就是指向某个commit的指针(跟分支很像对不对?但是分支可以移动,标签不能移动),所以,创建和删除标签都是瞬间完成的。 + +打新标签 git tag git tag -a v0.1 -m "version 0.1 released" 3628164 -a指定标签名,-m指定说明文字 3628164 指定commit id +查看标签git tag +查看标签信息git show + +小结 +命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; + +git tag -a -m "blablabla..."可以指定标签信息; + +git tag -s -m "blablabla..."可以用PGP签名标签; + +命令git tag可以查看所有标签。 + + +其它操作 + +git log 之后按q键返回正常模式 + +查看commit id:git log --pretty=oneline --abbrev-commit + +当出现分支合并问题后,可以用下面这句查看分支合并图:git log --graph --pretty=oneline --abbrev-commit diff --git a/XiaosThanks.txt b/XiaosThanks.txt new file mode 100644 index 0000000000..fbdc6da55e --- /dev/null +++ b/XiaosThanks.txt @@ -0,0 +1,2 @@ +Thank you for your perfect git tutorial. +Test for the pull request. diff --git a/YJack.txt b/YJack.txt new file mode 100644 index 0000000000..b73793a6b4 --- /dev/null +++ b/YJack.txt @@ -0,0 +1,3 @@ +Hello, Mr Liao. When I meet your blog, I begin to know that GIT is so powerful! It's far more better than SVN. +I'm not so clever as some friends. I spend whole week to understand you lesson. It really helps me. +Thank you from deep of my heart, Mr. Liao! You are such a great man! I wish you a happy life and job! diff --git a/YiZhuoChen.txt b/YiZhuoChen.txt new file mode 100644 index 0000000000..e5731fdcf7 --- /dev/null +++ b/YiZhuoChen.txt @@ -0,0 +1 @@ +The tutorials help me a lot. I love it. Thank you very much. diff --git a/ZhuXiaobing.txt b/ZhuXiaobing.txt new file mode 100644 index 0000000000..befc8c7c79 --- /dev/null +++ b/ZhuXiaobing.txt @@ -0,0 +1 @@ +thank you very much ,the tutorial is very good ,this tutorial gives me plenty of help.thank you angin! diff --git a/_thxforyourcontribution.txt b/_thxforyourcontribution.txt new file mode 100644 index 0000000000..88ccf32a08 --- /dev/null +++ b/_thxforyourcontribution.txt @@ -0,0 +1 @@ +pull request test! \ No newline at end of file diff --git "a/a - \345\211\257\346\234\254.txt" "b/a - \345\211\257\346\234\254.txt" new file mode 100644 index 0000000000..3f5aecf5f6 --- /dev/null +++ "b/a - \345\211\257\346\234\254.txt" @@ -0,0 +1,3 @@ +It's a test. +Thanks. +asdsada \ No newline at end of file diff --git a/a.txt b/a.txt new file mode 100644 index 0000000000..1eff8521b2 --- /dev/null +++ b/a.txt @@ -0,0 +1,6 @@ +It's a test. +Thanks. + + +hello +hehee \ No newline at end of file diff --git a/aMsgFromMe.txt b/aMsgFromMe.txt new file mode 100644 index 0000000000..9a702e2b10 --- /dev/null +++ b/aMsgFromMe.txt @@ -0,0 +1,2 @@ +Thanks, Liao~ +You're so nice~ \ No newline at end of file diff --git a/a_letter_from_liuweifly b/a_letter_from_liuweifly new file mode 100644 index 0000000000..b61f608f78 --- /dev/null +++ b/a_letter_from_liuweifly @@ -0,0 +1,8 @@ +Hi, Mr.Liao + +Thank you for providing this course. It is your course that helps me to know Git and GitHub. + +Thank you again, + + + liuweifly Oct.14th 2014 diff --git a/a_sponsor.txt b/a_sponsor.txt new file mode 100644 index 0000000000..466eeb81fb --- /dev/null +++ b/a_sponsor.txt @@ -0,0 +1,5 @@ +Hi, Mr.Liao + +Thank you for providing this course. It is your course that helps me to know Git and GitHub. + +Thank you again diff --git a/aaa-lisicong.txt b/aaa-lisicong.txt new file mode 100644 index 0000000000..a47fdd0a4e --- /dev/null +++ b/aaa-lisicong.txt @@ -0,0 +1 @@ +Thank you! \ No newline at end of file diff --git a/aac.txt b/aac.txt new file mode 100644 index 0000000000..5e52b1b07c --- /dev/null +++ b/aac.txt @@ -0,0 +1 @@ +这个教程不错喔 \ No newline at end of file diff --git a/admywork.txt b/admywork.txt new file mode 100644 index 0000000000..81277aa207 --- /dev/null +++ b/admywork.txt @@ -0,0 +1 @@ +This article gives me lots of help! Thanks. diff --git a/agaga.txt b/agaga.txt new file mode 100644 index 0000000000..5cbf72735e --- /dev/null +++ b/agaga.txt @@ -0,0 +1 @@ +try fork and push \ No newline at end of file diff --git a/ai.txt b/ai.txt new file mode 100644 index 0000000000..9342a0daba --- /dev/null +++ b/ai.txt @@ -0,0 +1 @@ +it is too hard. diff --git a/ai7hoo.txt b/ai7hoo.txt new file mode 100644 index 0000000000..91418aaefc --- /dev/null +++ b/ai7hoo.txt @@ -0,0 +1 @@ +Thanks for sharing. :) diff --git a/aknife.txt b/aknife.txt new file mode 100644 index 0000000000..f6d5f51d4c --- /dev/null +++ b/aknife.txt @@ -0,0 +1,3 @@ +test pull request +Thank you! + diff --git a/allenqi.txt b/allenqi.txt new file mode 100644 index 0000000000..9a305e21d0 --- /dev/null +++ b/allenqi.txt @@ -0,0 +1 @@ +Thanks very much! diff --git a/altaxa.txt b/altaxa.txt new file mode 100644 index 0000000000..bdadf9b0f7 Binary files /dev/null and b/altaxa.txt differ diff --git a/aluckcat.txt b/aluckcat.txt new file mode 100644 index 0000000000..34ad150330 --- /dev/null +++ b/aluckcat.txt @@ -0,0 +1,3 @@ +Hey , i am a luckcat from Nanjing . +I am learning GIT from your blog . +Lots of thanks for you . \ No newline at end of file diff --git a/alvingeek.txt b/alvingeek.txt new file mode 100644 index 0000000000..5c7b5e0732 --- /dev/null +++ b/alvingeek.txt @@ -0,0 +1,6 @@ +Dear Liao, + How are you these days? I am so pleased that I have chance to get your Git and python tutorial. I hope you know how I appreciate your help. + I think the tutorial you write is so simply ,clear and cool. your are really a good teacher, I can learn this skill very efficiently. After learn this skill I have a strong desire to do sth helpful for the open source community. + Thank you for you many kindness and I wish you are happy everyday. + Sincerely yours, + Alvin diff --git a/amazing.txt b/amazing.txt new file mode 100644 index 0000000000..7441fcfe7c --- /dev/null +++ b/amazing.txt @@ -0,0 +1 @@ +快快接受我的pull request \ No newline at end of file diff --git a/andy.txt b/andy.txt new file mode 100644 index 0000000000..3b2993882d --- /dev/null +++ b/andy.txt @@ -0,0 +1 @@ +Thanks for sharing \ No newline at end of file diff --git a/annging.txt b/annging.txt new file mode 100644 index 0000000000..6cfbfc3e0a --- /dev/null +++ b/annging.txt @@ -0,0 +1,3 @@ +I feel so sorry that I can't wirte this in Chinese and My English is pool. + +I write this for test the function of "pull reqest" \ No newline at end of file diff --git a/anselxia.txt b/anselxia.txt new file mode 100644 index 0000000000..d88a547729 --- /dev/null +++ b/anselxia.txt @@ -0,0 +1 @@ +thank you for your articles diff --git a/aproabra.txt b/aproabra.txt new file mode 100644 index 0000000000..0b056a48c0 --- /dev/null +++ b/aproabra.txt @@ -0,0 +1,9 @@ +非常感谢您的GIT学习教程. + +之前也用GIT的,但是,没有系统的学习过. + +这次看了您的教程,受益匪浅. + +您的教程,思维清晰,深入浅出,很容易理解,是学习GIT的好教程!! + +赞!!! \ No newline at end of file diff --git a/arsentu.txt b/arsentu.txt new file mode 100644 index 0000000000..a6171a160d --- /dev/null +++ b/arsentu.txt @@ -0,0 +1,130 @@ + • git --version + + • git config + $ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" + $ git config -l // 列出所有config + + • git init + $ git init + + • git add + $ git add readme.txt + $ git add . + + • git commit + $ git commit -m "wrote a readme file" + + • git status + $ git status + + • git diff + $git diff readme.txt + $git diff + $git diff HEAD -- readme.txt + $git diff origin/dev dev // 看本地dev分支与远程的dev分支的diff + $git diff master dev // 查看本地dev分支与本地master分支的diff + $git diff origin/master dev // 查看本地dev分支与远程master分支的diff + $git diff origin/dev // 将当前缺省分支与远程dev分支进行比较 + + • git log + $git log + $git log --pretty=oneline // 每个commit显示为一行 + $git log --graph --pretty=oneline --abbrev-commit + + • git reset + $git reset --hard HEAD^ + $git reset --hard 16ce9d3 + $git reset HEAD readme.txt // 将暂存区清空,工作区不受影响 + + • git reflog + $git reflog + + • git checkout + $git checkout -- readme.txt // 用“版本库 merged with 暂存区”中的内容替换工作区中的内容,相当于revert(放弃还没有提交的修改) + $git checkout dev // 切换到分支dev + // 如果当前分支上没有修改,可以切换,切换分支时会修改工作区的内容为新分支的内容 + // 如果当前分支上有修改,切换的分支对应的commit一样,则工作区中还没有提交的修改会留着 + // 如果当前分支上有修改,切换的分支对应的commit不一样,则不能切换,要么将修改stash, 要么将修改revert(cheout -- file), 也就是将修改清空后再进行切换 + $git checkout -b dev // 切换到分支dev, -b 分支不存在的情况下先创建分支 + $git checkout -b dev origin/dev // 在本地创建和远程对应的分支,名称最好一致 + + • git branch + $git branch dev // 创建分支dev + $git branch // 查看本地分支 + $git branch -a // 查看所有分支,包括远程分支 + $git branch -d dev // 删除分支 -D强行删除(对于还没有合并的分支)。要删除一个分支,需要跑到另一个分支下去删 + $git branch --set-upstream dev origin/dev // 将本地分支与远程分支关联 + + • git remote + $git remote // 查看远程仓库有关的信息 + $git remote -v // 详细信息 + $git remote show origin // 关于远程仓库origin更详细的信息(有哪些分支,以及分支的状态) + $git remote update // 让本地获知远程仓库有关的信息 + // 对于新建的branch,状态为new而不是tracked, 则需要先update一下 + // 远程仓库已经更新过了,但本地还不知道,需要更新一下 (否则status, diff信息不准),但不会改本地的仓库及工作区的内容 + // 会列出来远程做过什么update (别人做的) + $git remote add origin https://github.com/arsentu/learngit.git // 将本地的仓库和远程的仓库建立关联 origin代表远程的名字,后面的url是远程的具体位置 + $git remote set-url origin git@git.oschina.net:arsentu/learngit.git // 更改远程origin对应的位置 + + • git push + $git push -u origin master // -u 第一次远程还没有master分支的时候用,并把本地的master分支与远程的master分支建立关联 + $git push origin master // 后续的推送(master分支)不再需要-u参数 + $git push origin dev // 将本地的dev分支push到远端 + $git push // 将当前没有同步的分支都进行push , 可能push多个分支 + $git push origin v1.0 // 将标签推送到远程 + $git push origin --tags // 将所有标签都推送到远程 + $git push origin :refs/tags/v0.5 // 先用git tag -d v0.5删除本地标签,再将删除推送到远程,在远程上也删除之 + + • git pull + $git pull // 只将当前branch的内容与远程同步,但是会显示所有远程更新的信息(相当于背后做了git remote update ?) + $git pull origin master:master // 从远程的master pull到本地的master + $git pull origin master // 从远程origin的master pull到本地的当前branch + $git pull origin // 从远程origin中与当前branch对应的branch进行pull + $git pull // 只有一个远程时,远程用缺省的,本地branch用当前的,远程branch用与当前branch对应的 + $git pull origin master:user1 // 从远程的master pull到本地的user1, 不会改变user1的追踪(映射)关系 + + • git fetch + $git fetch origin // 获取远程有关的信息,但是不会修改工作区的内容,便于看与远程的diff? 获取的是什么? 和git remote update的效果一样? + // origin相当于远程在本地的镜像,fetch是将本地镜像与远程同步?gite remote update也可以 + $git fetch foobar // foobar是另一个远程的名字 + $git fetch // 获取缺省的远程 + + • git rm + $git rm test.txt + + • ssh-keygen + $ssh-keygen -t rsa -C "yourname@example.com" + + • git remote add + $git remote add origin git@github.com:arsentu/learngit.git // 在本地工作git工作区目录下运行,将本地仓库与远程仓库关联 + + • git clone + $git clone git@github.com:arsentu/gitskills.git + + + • git merge + $git merge dev // 将dev分支合并到当前分支,合并会修改当前分支对应的版本库中的内容 + $git merge --no-ff -m "merge with no-ff" dev // 禁用非Fast-forward方式merge, 会产生新的commit + + • git stash + $git stash // 暂存工作现场,同时revert 工作区 + $git stash list // 列出存过的工作现场 + $git stash apply // 恢复工作现场 + $git stash apply stash@{0} // ? + $git stash drop // 删除保存的工作现场 + $git stash pop // 恢复工作现场并删除存储的工作现场 相当于apply + drop + + • git help + $git help log + + • git tag + $git tag v1.0 // 打标签 + $git tag // 查看标签列表 + $git tag v0.5 102cdf77a6f3c7b228b449145c3f531679cf73cb // 给以前的某次commit补打标签 + $git tag -a v0.1 -m "initial version: readme.txt" 330f5cff5c1849730ef94b // -a 标签名,-m 描述信息 + $git tag -d v0.5 // 删除标签 + + • git show + $git show v0.5 // 查看某个标签 + diff --git a/azlarsin.txt b/azlarsin.txt new file mode 100644 index 0000000000..bd51448598 --- /dev/null +++ b/azlarsin.txt @@ -0,0 +1,3 @@ +hi, michael + + diff --git a/banjnax.txt b/banjnax.txt new file mode 100644 index 0000000000..b67f169063 --- /dev/null +++ b/banjnax.txt @@ -0,0 +1,142 @@ +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +通过git init命令把这个目录变成Git可以管理的仓库: +用命令git add告诉Git,把文件添加到仓库:$ git add readme.txt +Unix的哲学是“没有消息就是好消息” +用命令git commit告诉Git,把文件提交到仓库:$ git commit -m "wrote a readme file" +add会把修改放到暂存区,commit会把暂存区里的内容提交到当前分支。 +时刻注意git status,查看修改差异,利用git diff,commit前要add. +利用git log来查看我们队文件都做了哪些改动。如果嫌输出信息太多,看得眼花缭乱的,可以试试加上--pretty=oneline参数: + +如何回退: +1.首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交3628164...882e1e0(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。 +2.就可以使用git reset命令来回退,如git reset --hard HEAD^(回退到上一个版本) +3.如果当前页面没有消失可以找到版本的id,页面如果要回去可以用$ git reset --hard 3628164,这两个步骤主要是把指针来回的移动罢了。 +4.要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。查看commit id就行。 + +GIT管理的是修改,add是把修改放到了暂存区,commit是把暂存区的修改提交,所以每次修改一定要add, + +命令git checkout -- readme.txt意思就是,把readme.txt文件在工作区的修改全部撤销,这里有两种情况: + +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; + +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 + +总之,就是让这个文件回到最近一次git commit或git add时的状态。 + +git checkout -- file命令中的--很重要,没有--,就变成了“创建一个新分支”的命令,我们在后面的分支管理中会再次遇到git checkout命令。 + +Git同样告诉我们,用命令git reset HEAD file可以把暂存区的修改撤销掉(unstage),重新放回工作区: + +******************************************************************************* +梳理一下:首先文件夹下有两个部分,工作区和版本区,在工作区中是我们实体的文件copy,在版本区中是进行版本控制的内容(也就是修改和工作区的最新文件备份),其中管理的是修改。我们用的git xx命令就是在版本区执行的,我们用的rm,touch等是在工作区执行的。在工作区执行后,就产生了一次修改,git把这些修改放到版本区的暂存区(利用add命令),如果没有放到暂存区的话,git status会有说明的,因为我们只有把修改放到暂存区中我们才可以进行提交等(因为暂存区给了我们一次可以反悔的机会,我们可以checkout 和 reset). +举一个比较好的例子:删除工作区的一个文件rm test.txt,这对于GIT来说是一个修改,这个修改会立刻反应给GIT(因为它在工作区已经不存在了,所以add到暂存区是没有意义的),如果你真的要删除他的话,可以用git rm test.txt 把他也从版本库中删除,然后git commit 提交,这样版本库中和工作区中都没有了,如果是误删除,因为版本区里还有一个最新的备份,因此可以用checkout回复到工作区。 + +******************************************************************************* + +实际情况往往是这样,找一台电脑充当服务器的角色,每天24小时开机,其他每个人都从这个“服务器”仓库克隆一份到自己的电脑上,并且各自把各自的提交推送到服务器仓库里,也从服务器仓库中拉取别人的提交。 + +当然,GitHub允许你添加多个Key。假定你有若干电脑,你一会儿在公司提交,一会儿在家里提交,只要把每台电脑的Key都添加到GitHub,就可以在每台电脑上往GitHub推送了。 +一、推送给远程 +1.我们根据GitHub的提示,在本地的learngit仓库下运行命令: +现在github上创建一个learngit.git的repo然后在本地git文件夹下运行。 +$ git remote add origin git@github.com:michaelliao/learngit.git//或者是http://github.com/banjnax/LeaGit.git +请千万注意,把上面的michaelliao替换成你自己的GitHub账户名,否则,你在本地关联的就是我的远程库,关联没有问题,但是你以后推送是推不上去的,因为你的SSH Key公钥不在我的账户列表中。 +添加后,远程库的名字就是origin,这是Git默认的叫法,也可以改成别的,但是origin这个名字一看就知道是远程库。 +2.下一步,就可以把本地库的所有内容推送到远程库上:$ git push -u origin master +把本地库的内容推送到远程,用git push命令,实际上是把当前分支master推送到远程。 +由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。 +3.此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +二、从远程拉去 +1.$ git clone git@github.com:michaelliao/gitskills.git//或者http://github.com/banjnax/LeaGit.git +之后会在本地创建一个相对应的文件夹 + +三、分支的创建于使用 +HEAD严格来说不是指向提交,而是指向master,master才是指向提交的,所以,HEAD指向的就是当前分支。 +一开始的时候,master分支是一条线,Git用master指向最新的提交,再用HEAD指向master,就能确定当前分支,以及当前分支的提交点: +当我们创建新的分支,例如dev时,Git新建了一个指针叫dev,指向master相同的提交,再把HEAD指向dev,就表示当前分支在dev上:不过,从现在开始,对工作区的修改和提交就是针对dev分支了,比如新提交一次后,dev指针往前移动一步,而master指针不变:假如我们在dev上的工作完成了,就可以把dev合并到master上。Git怎么合并呢?最简单的方法,就是直接把master指向dev的当前提交,就完成了合并:所以Git合并分支也很快!就改改指针,工作区内容也不变!合并完分支后,甚至可以删除dev分支。删除dev分支就是把dev指针给删掉,删掉后,我们就剩下了一条master分支: +1.命令 +$ git checkout -b dev +git checkout命令加上-b参数表示创建并切换,相当于以下两条命令: +$ git branch dev +$ git checkout dev +然后,用git branch命令查看当前分支: + +$ git branch +* dev + master +git branch命令会列出所有分支,当前分支前面会标一个*号。 +git push origin MyBr//把分支push到远端 +2.合并分支内容到master +$ git merge dev//注意这个事在master分支内运行的,表示把master合并到dev分支处 +3.合并完成后,就可以放心地删除dev分支了:$ git branch -d dev +4.注意在本地push到远端,如果想保持同步,需要把分支和master分别push到github。删除了本地分支就不能再本地同步到github上了,需要自己在github上删除,不过话又说回来了,一般来说我们只是clone远端的master,然后在本地建一个分支,然后在本地分支上修改什么的,然后合并为master,最后通过master push到github,最后在本地删除我们的分支。所以。。把我们的分支push 到github上是没有必要的。 + +四、冲突 +1.如果多个分支对同一个文件进行了修改提交,并且分支之间进行了meger就会发生冲突。 +2.解决,我们在master上修改冲突文件,因为这是一个修改所以我们add,commit就好了,这时master比其他分支多一层,就解决了冲突问题。git log --graph命令可以看到分支合并图。 + +--no-ff参数,表示禁用Fast forward://merge时 +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 +五、stash +对于你在分支上工作时,突然来了另一个紧急的任务,但是你的工作还没有做完怎么办呢,那就是先把当前的现场环境保留下来git stash;然后就可以去做其他事了,做完了其他事,回到本分支,用git stash list命令看看保留的现场环境:工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: + +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; + +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,用命令: + +$ git stash apply stash@{0} + +六、多人协作 +多人协作的工作模式通常是这样: +首先,可以试图用git push origin branch-name推送自己的修改; + +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +如果合并有冲突,则解决冲突,并在本地提交; + +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单。 +七、标签 +在Git中打标签非常简单,首先,切换到需要打标签的分支上: +然后,敲命令git tag 就可以打一个新标签: + +$ git tag v1.0 +可以用命令git tag查看所有标签: + +$ git tag +v1.0 +默认标签是打在最新提交的commit上的。有时候,如果忘了打标签,比如,现在已经是周五了,但应该在周一打的标签没有打,怎么办? + +方法是找到历史提交的commit id,然后打上就可以了: +比方说要对add merge这次提交打标签,它对应的commit id是6224937,敲入命令: + +$ git tag v0.9 6224937 +注意,标签不是按时间顺序列出,而是按字母排序的。可以用git show 查看标签信息: +还可以创建带有说明的标签,用-a指定标签名,-m指定说明文字: + +$ git tag -a v0.1 -m "version 0.1 released" 3628164 +用命令git show 可以看到说明文字: +如果标签打错了,也可以删除: + +$ git tag -d v0.1 +因为创建的标签都只存储在本地,不会自动推送到远程。所以,打错的标签可以在本地安全删除。 + +如果要推送某个标签到远程,使用命令git push origin : +或者,一次性推送全部尚未推送到远程的本地标签: + +$ git push origin --tags + +如何参与一个开源项目呢?比如人气极高的bootstrap项目,这是一个非常强大的CSS框架,你可以访问它的项目主页https://github.com/twbs/bootstrap,点“Fork”就在自己的账号下克隆了一个bootstrap仓库, +一定要从自己的账号下clone仓库,这样你才能推送修改。如果从bootstrap的作者的仓库地址git@github.com:twbs/bootstrap.git克隆,因为没有权限,你将不能推送修改。 + +如果你想修复bootstrap的一个bug,或者新增一个功能,立刻就可以开始干活,干完后,往自己的仓库推送。 + +如果你希望bootstrap的官方库能接受你的修改,你就可以在GitHub上发起一个pull request。当然,对方是否接受你的pull request就不一定了。 + +如果你没能力修改bootstrap,但又想要试一把pull request,那就Fork一下我的仓库:https://github.com/michaelliao/learngit,创建一个your-github-id.txt的文本文件,写点自己学习Git的心得,然后推送一个pull request给我,我会视心情而定是否接受。 \ No newline at end of file diff --git a/baokang.txt b/baokang.txt new file mode 100644 index 0000000000..a17077978a --- /dev/null +++ b/baokang.txt @@ -0,0 +1 @@ +NICE! \ No newline at end of file diff --git a/bear.txt b/bear.txt new file mode 100644 index 0000000000..f331f10278 --- /dev/null +++ b/bear.txt @@ -0,0 +1,10 @@ +This is a test for pull request +Thank you for your course ,teacher Liao~ +I've learned a lot about git, +and this is my first time to enter the world of github +It is very important to me! +Happy new year ! + + + +i modify this file on local dev \ No newline at end of file diff --git a/bee1989.txt b/bee1989.txt new file mode 100644 index 0000000000..084e03c263 --- /dev/null +++ b/bee1989.txt @@ -0,0 +1 @@ +Thank you for your tutorial! \ No newline at end of file diff --git a/beiyi.txt b/beiyi.txt new file mode 100644 index 0000000000..61ee2207ea --- /dev/null +++ b/beiyi.txt @@ -0,0 +1,5 @@ +感谢廖雪峰给我们贡献了如此浅显易懂的git教程。 +我不是一名程序员,但靠带领别人认识程序世界为职业。 +我希望将来能通过这里所学的知识,把自己的一些学习体会和代码放在github上和大家分享。 + +如果说我对git的学习心得,那就是我把git看作vmware虚拟机快照管理器一样的东西。只不过做快照的对象是文本内容。 diff --git a/betterzfz.txt b/betterzfz.txt new file mode 100644 index 0000000000..bd08d69207 --- /dev/null +++ b/betterzfz.txt @@ -0,0 +1 @@ +some code \ No newline at end of file diff --git a/bigbigbug.txt b/bigbigbug.txt new file mode 100644 index 0000000000..25162e0efc --- /dev/null +++ b/bigbigbug.txt @@ -0,0 +1 @@ +thank you. diff --git a/bill.txt b/bill.txt new file mode 100644 index 0000000000..5ad28e2276 --- /dev/null +++ b/bill.txt @@ -0,0 +1 @@ +haha diff --git a/bin-git-id.txt b/bin-git-id.txt new file mode 100644 index 0000000000..a47fdd0a4e --- /dev/null +++ b/bin-git-id.txt @@ -0,0 +1 @@ +Thank you! \ No newline at end of file diff --git a/blastbao.txt b/blastbao.txt new file mode 100644 index 0000000000..c5ac549826 --- /dev/null +++ b/blastbao.txt @@ -0,0 +1,2 @@ +Very thanks! +I have learned Git through your blog. diff --git a/bobhuang-github-id.txt b/bobhuang-github-id.txt new file mode 100644 index 0000000000..dda6d31a9f --- /dev/null +++ b/bobhuang-github-id.txt @@ -0,0 +1,2 @@ +Michael Liao,I have learned how to make full use of git after reading your teaching blog. +Thank you very much! You are my idol. diff --git a/borisliu.txt b/borisliu.txt new file mode 100644 index 0000000000..b87e1f441c --- /dev/null +++ b/borisliu.txt @@ -0,0 +1 @@ +很好的教程,谢谢! diff --git "a/branch\345\221\275\344\273\244 \345\260\217\347\273\223" "b/branch\345\221\275\344\273\244 \345\260\217\347\273\223" new file mode 100644 index 0000000000..96ebe5421f --- /dev/null +++ "b/branch\345\221\275\344\273\244 \345\260\217\347\273\223" @@ -0,0 +1,27 @@ + +谢谢雪峰老师的经典教程!这两天我边看边练习. +这是我第一次在github上测试pull request. + +下面是我一边看教程,一边实践,然后总结出来的一些有关分支(branch)的命令: + +创建分支:git branch +查看分支:git branch + +删除分支: +git branch -d 删除本地已经commit的分支 +git branch -D 删除本地还未commit的分支 +加强说明:在B分支状态下,无法删除B分支.必须切换到其他分支状态下,才能删除B分支. + +切换分支:git checkout +创建+切换分支:git checkout -b + +合并某分支到当前分支:git merge + +协作完成项目时,为了把远程分支的更新同步(pull)到本地相应的分支,需先设置好二者的链接: +git branch --set-upstream origin/ + +...... + +暂时先写这些.若有不足之处,恳请朋友们斧正:) + + diff --git a/bravery-github-id.txt b/bravery-github-id.txt new file mode 100644 index 0000000000..4da99bbbf2 --- /dev/null +++ b/bravery-github-id.txt @@ -0,0 +1,2 @@ +http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137628548491051ccfaef0ccb470894c858999603fedf000 +This is a excellent git tutorial diff --git a/bupt-Jerry.thank b/bupt-Jerry.thank new file mode 100644 index 0000000000..f4f95520a8 --- /dev/null +++ b/bupt-Jerry.thank @@ -0,0 +1,7 @@ +Dear Liao: + I am a graduate student from Beijing Univ. of Posts and Telecom. I followed your weibo and knew you are also graduated form BUPT. I learned a lot from your blog teaching Git. It is amazing that I find most of technique blogs are written by allumnus of our school. + + +Best wished! +Have a nice day! +Jiarui Fang diff --git a/buptgao.txt b/buptgao.txt new file mode 100644 index 0000000000..264350b9cf --- /dev/null +++ b/buptgao.txt @@ -0,0 +1 @@ +廖雪峰老实的git教程真是生动有趣,学起来轻松又愉快,希望出更多更好的精品教程 diff --git a/bupttest.txt b/bupttest.txt new file mode 100644 index 0000000000..c5f9ef2adb --- /dev/null +++ b/bupttest.txt @@ -0,0 +1 @@ +really nice to have liao's lesson! thank u! \ No newline at end of file diff --git a/byr-gdp.txt b/byr-gdp.txt new file mode 100644 index 0000000000..ec7176cc26 --- /dev/null +++ b/byr-gdp.txt @@ -0,0 +1 @@ +hello guy, thanks for your tutorial on git diff --git a/bzhui.txt b/bzhui.txt new file mode 100644 index 0000000000..1ae0973b96 --- /dev/null +++ b/bzhui.txt @@ -0,0 +1 @@ +bzhui diff --git a/caike007.txt b/caike007.txt new file mode 100644 index 0000000000..6c61518b20 --- /dev/null +++ b/caike007.txt @@ -0,0 +1,3 @@ +I am a UI designer, good at visual design, interaction design, but coding is not my strengh, +github is a good place to draw lessons and improve myself quickly, +thanks for your intruduction. \ No newline at end of file diff --git a/caimaoy@gmail.com b/caimaoy@gmail.com new file mode 100644 index 0000000000..59176a00bc --- /dev/null +++ b/caimaoy@gmail.com @@ -0,0 +1,11 @@ +# -*- coding: UTF-8 -*- + +''' +Last modified time: 2015-01-04 11:51:08 +Edit time: 2015-01-04 11:51:53 +File name: caimaoy@gmail.com +Edit by caimaoy +''' + +if __name__ == '__main__': + print 'THX' diff --git a/candywxt.txt b/candywxt.txt new file mode 100644 index 0000000000..1767f6eae8 --- /dev/null +++ b/candywxt.txt @@ -0,0 +1,3 @@ +感谢~~ +教程很好!浅显易懂!非常感谢! +昨天并不是用git bash pr 的,今天练习了一下在git bash里面敲命令行,发现也很方便! \ No newline at end of file diff --git a/candywxtlearnmore.txt b/candywxtlearnmore.txt new file mode 100644 index 0000000000..de2d3c16b9 --- /dev/null +++ b/candywxtlearnmore.txt @@ -0,0 +1,24 @@ +回忆一下今天学到的几个命令 +cd e:/ 到指定的目录下 +mkdir 建立一个版本库 +pwd 查看当前目录位置 +git init 初始化一个仓库 +git add file 添加一个文件 +git commit -m "写上你每一次的修改" +git status 查看工作区状态 +git log 查看历史记录 +git log -graph 以图形化形式查看记录 +git log --pretty=onelinte 简化记录 +git branch 查看分支 +git checkout -b bev 创建bev分支并切换到bev分支下 +git merge dev 合并分支 +git merge --no-ff -m "禁止快速合并" dev +git remote add origin git@github.com:candywxt/XXX 关联一个仓库 +git push -u origin master 首次push +git push origin master 以后push +git clone git@github.com:candywxt/XXX.git clone一个仓库 +rm 删除文件 +git rm 删除版本库中的文件 +git stash 保护现场 +git stash list 保险现场的list +git stash pop 恢复现场并且删除stash diff --git a/caolicheng.txt b/caolicheng.txt new file mode 100644 index 0000000000..fcd4cbc374 --- /dev/null +++ b/caolicheng.txt @@ -0,0 +1 @@ +大神你好,我学习了,谢谢你 \ No newline at end of file diff --git a/caopengfei.txt b/caopengfei.txt new file mode 100644 index 0000000000..4fafc92436 --- /dev/null +++ b/caopengfei.txt @@ -0,0 +1,3 @@ +非常感谢廖雪峰老师得git教程,将我带入了git世界; +也是因为git教程然后使用了github,进入到开源的大世界; +再次感谢廖雪峰老师! diff --git a/captain_xk.txt b/captain_xk.txt new file mode 100644 index 0000000000..f09e1314d9 --- /dev/null +++ b/captain_xk.txt @@ -0,0 +1,2 @@ +Thank you for your tutorial,Michael! +我表示看到一个家伙做了一份非常棒的笔记,这里表示强烈推荐收藏,就是cloudstone.txt这份文件,非常感谢! \ No newline at end of file diff --git a/captainwong.txt b/captainwong.txt new file mode 100644 index 0000000000..cb514b3e72 --- /dev/null +++ b/captainwong.txt @@ -0,0 +1,4 @@ +Thx for you contribution! +I'm a fresh bird on git, thx your outstanding articles for helping me learn git. +Respects +captainwong \ No newline at end of file diff --git a/carlos121493.txt b/carlos121493.txt new file mode 100644 index 0000000000..b385a7c565 --- /dev/null +++ b/carlos121493.txt @@ -0,0 +1 @@ +感谢老师教的内容,让我对git以及版本发布有了比较深的认识,通过操作了解git的原理,这让在工作中用不到git的同学有了很好的途径认识,希望能被pull request \ No newline at end of file diff --git a/cassie_git.txt b/cassie_git.txt new file mode 100644 index 0000000000..ccdb6105e4 --- /dev/null +++ b/cassie_git.txt @@ -0,0 +1,4 @@ +This is my first learn to pull request git. +I love reading your git course. +I find learning git is so interesting. +I hope you could allow my pull request diff --git a/ccqy-git-learn.txt b/ccqy-git-learn.txt new file mode 100644 index 0000000000..f41645d392 --- /dev/null +++ b/ccqy-git-learn.txt @@ -0,0 +1,4 @@ +Thanking for giving a lesson for me to learn git, +all the time,I just want to learn git,but don't have a good lesson, +I get it until I found this lesson. +I appreciate it realy. \ No newline at end of file diff --git a/changshun b/changshun new file mode 100644 index 0000000000..dc6a77b785 --- /dev/null +++ b/changshun @@ -0,0 +1,3 @@ +I am a graduate student in Xiamen University. +I am not good at coding. +Thank u for writing this tutorial. diff --git a/chenglong365.txt b/chenglong365.txt new file mode 100644 index 0000000000..a04e0e328e --- /dev/null +++ b/chenglong365.txt @@ -0,0 +1,4 @@ +测试pull request +================== + +非常棒的Git教程,之前也学习过好几次Git,都是学的晕晕乎乎,始终搞不明白。直到接触到廖老师的Git教程,短短几个小时,浅显易懂,step by step的实践,开始喜欢上Git了。原来Git这么棒。多谢廖老师。Good work。 \ No newline at end of file diff --git a/chenleilei.txt b/chenleilei.txt new file mode 100644 index 0000000000..7163de1774 --- /dev/null +++ b/chenleilei.txt @@ -0,0 +1 @@ +Thanks Mr Liao for git. diff --git a/chenzhijun.txt b/chenzhijun.txt new file mode 100644 index 0000000000..68d9b8c78a --- /dev/null +++ b/chenzhijun.txt @@ -0,0 +1 @@ +some sentence will throw exception : eg:git remote add..... there will be .... diff --git a/christine.txt b/christine.txt new file mode 100644 index 0000000000..d808774751 --- /dev/null +++ b/christine.txt @@ -0,0 +1 @@ +Thanks for your sharing. Your course is awesome. \ No newline at end of file diff --git a/chunyu.txt b/chunyu.txt new file mode 100644 index 0000000000..040cf679fb --- /dev/null +++ b/chunyu.txt @@ -0,0 +1,5 @@ +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. + +By yangchunyu 2015,5,25 diff --git a/cloudstone.txt b/cloudstone.txt new file mode 100644 index 0000000000..6644d25ce6 --- /dev/null +++ b/cloudstone.txt @@ -0,0 +1,44 @@ + +git init 创建版本库 +git add 添加文件到缓冲区 +git commit -m ‘xxx’ 提交到本地仓库 +git status 查看当前目录状态 +git diff 查看文件变化的内容 +git reset --hard HEAD^ 回退到上一版本, git reset --hard HEAD^^ 回退到上上版本,git reset --hard HEAD~100 回退到上100个版本,git reset —hard 回退到指定版本 +git reflog 查看历史版本,如果有需要,随后可以根据显示的commit id进行回退 +git add后如果又修改了,此时git commit只会提交add过的版本,后面修改的不会提交 +git checkout -- revert文件到add过或最新的版本,先add的版本,再最新的版本 +git reset HEAD 可以撤销git add的版本 +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 + +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 + +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + + +git rm 会同时删除仓库里的文件和本地文件,但是在提交之前,还是可以通过git reset HEAD && git checkout —- 恢复文件 +git rm 相当于本地rm 再git add +git remote add origin git@server-name:path/repo-name.git 关联一个远程库 +git push -u origin master第一次推送master分支的所有内容 +git push origin master推送最新修改(对远程库非第一次) +git branch 查看分支 +git branch 创建分支 +git checkout 切换分支 +git checkout -b 创建+切换分支 +git merge 合并某分支到当前分支 +git branch -d 删除分支 +git log —graph 查看分支合并图 +git stash 保存工作现场 +git stash list 查看保存的stash +git stash apply stash@{n} 恢复指定的stash +git stash pop stash@{n} 恢复现场并删除该stash +如果一个分支没有被合并过,git branch -d feature 会被友情提醒,需要通过git branch -D feature 强行删除 +git tag 新建一个标签,默认为HEAD,也可以指定一个commit id; +git tag -a -m "blablabla..."可以指定标签信息; + +git tag -s -m "blablabla..."可以用PGP签名标签; +git tag可以查看所有标签。 +git push origin 可以推送一个本地标签; +git push origin --tags可以推送全部未推送过的本地标签; +git tag -d 可以删除一个本地标签; +git push origin :refs/tags/可以删除一个远程标签。 \ No newline at end of file diff --git a/codeplayer2org.txt b/codeplayer2org.txt new file mode 100644 index 0000000000..b99e78d1b7 --- /dev/null +++ b/codeplayer2org.txt @@ -0,0 +1 @@ +作者写的这本git教程生动有趣,相比其他的git教程,如git magic、pro git等容易理解的多,能够快速上手并在项目中实际使用。谢谢。 diff --git a/coderZdg.txt b/coderZdg.txt new file mode 100644 index 0000000000..ce4b3a9625 --- /dev/null +++ b/coderZdg.txt @@ -0,0 +1 @@ +Really Thankyou , liao! diff --git a/coneo.txt b/coneo.txt new file mode 100644 index 0000000000..561b34f7a1 --- /dev/null +++ b/coneo.txt @@ -0,0 +1,5 @@ +朋友开始推荐的一个git教程就是这个,忘了存,后来发现在百度搜“git教程”,出现的第一个链接就是雪峰的站。 +接触git应该是两年前了,那是在大学的时候,当时是想玩玩github才接触的,到现在git算是用的比较频繁。但是 +git的功能用的其实不多,因为主要都是在github上自己写写东西,并没有实际参与到开源中去。(都是题外话了) + +话说回来,这个教程写的特别棒,通俗易懂,对git的整个特性都有了了解,期待在以后有更多的实践。 diff --git a/csyangbinbin.txt b/csyangbinbin.txt new file mode 100644 index 0000000000..0db9e69e15 --- /dev/null +++ b/csyangbinbin.txt @@ -0,0 +1 @@ +so simple GIT lesson! diff --git a/cuihao0532 b/cuihao0532 new file mode 100644 index 0000000000..4fbcef1530 --- /dev/null +++ b/cuihao0532 @@ -0,0 +1,2 @@ +之前看过这个git教学系列,但没有坚持下来。 +这两天重新拾起了这个教学,咱一个! diff --git a/cuihongbo.txt b/cuihongbo.txt new file mode 100644 index 0000000000..b3ff0144b0 --- /dev/null +++ b/cuihongbo.txt @@ -0,0 +1,4 @@ +I'm a zol phper +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. \ No newline at end of file diff --git a/cuimingliang.txt b/cuimingliang.txt new file mode 100644 index 0000000000..a67a7bc12c --- /dev/null +++ b/cuimingliang.txt @@ -0,0 +1,2 @@ +enjoy your interesting git tutorial, and i have a little suggestion, if a beginner mistake for the url of origin when typing "git remote add +origin xxxxxx" then he cant use the origin to push anything, if he doesnt how to remove it ~ thank your wonderful narratives ~ diff --git a/cx.txt b/cx.txt new file mode 100644 index 0000000000..7263c01a88 --- /dev/null +++ b/cx.txt @@ -0,0 +1 @@ +Great git tutotial help me one day to be familiar with git. \ No newline at end of file diff --git a/daleiyang.txt b/daleiyang.txt new file mode 100644 index 0000000000..31e92cb085 --- /dev/null +++ b/daleiyang.txt @@ -0,0 +1 @@ +感谢! \ No newline at end of file diff --git a/daoxunchen.txt b/daoxunchen.txt new file mode 100644 index 0000000000..83ea4f982a --- /dev/null +++ b/daoxunchen.txt @@ -0,0 +1,5 @@ +Thank you very much! +This is the best learning guide I have ever seen. +Have a nice day!!! + +Bye! diff --git a/darkHorse.txt b/darkHorse.txt new file mode 100644 index 0000000000..669f5b1483 --- /dev/null +++ b/darkHorse.txt @@ -0,0 +1,5 @@ +因为廖老师的这个浅显易懂的Git教程,让我这个SVN使用者两天时间就上手了git,真是受益匪浅啊~ +掌握了这些充分必要的Git命令再结合Pro Git的中文教程,从此我不会再用SVN管理项目了。 +廖老师的Git教程真的是良心之作呀,向您致敬! + +PS:向"极客之王"Linus致敬,这是必须的~ diff --git a/david-liao.txt b/david-liao.txt new file mode 100644 index 0000000000..344c4cb665 --- /dev/null +++ b/david-liao.txt @@ -0,0 +1,3 @@ +Hi, Michael +This guide of Git is awesome! +This file is for testing pull request. diff --git a/davidcr-github-id.txt b/davidcr-github-id.txt new file mode 100644 index 0000000000..bbade02f9f --- /dev/null +++ b/davidcr-github-id.txt @@ -0,0 +1 @@ +仅仅是为了测试用的 diff --git a/deedzhouy.txt b/deedzhouy.txt new file mode 100644 index 0000000000..edcafce39d --- /dev/null +++ b/deedzhouy.txt @@ -0,0 +1 @@ +感谢您的教程,对GIT小白帮助很大,必须赞助一下。嘿嘿!! diff --git a/devmidai.txt b/devmidai.txt new file mode 100644 index 0000000000..e7f1057034 --- /dev/null +++ b/devmidai.txt @@ -0,0 +1,2 @@ +这是我见过最好的一个Git课程,终于算是懂了!!! +赞助了20元,谢谢廖老师。 \ No newline at end of file diff --git a/dhn.txt b/dhn.txt new file mode 100644 index 0000000000..f556d03824 --- /dev/null +++ b/dhn.txt @@ -0,0 +1,2 @@ +hello git +thank you! \ No newline at end of file diff --git a/dhs789520.txt b/dhs789520.txt new file mode 100644 index 0000000000..1b0ca810d6 --- /dev/null +++ b/dhs789520.txt @@ -0,0 +1,18 @@ +对一个医生来讲 + +学习计算机已经很不错 + +学习编程已经了了 + + +学习编程的时候还在学习 软件工程,比如git 这样的,几乎找不到同行了 + + +且学且珍惜,谢谢廖老师 + + +如果有一天,我开源项目可以提升自己20%的薪水,会再次来感谢你 + + +你的教程做的非常的好,一步一步跟着教程来,就很容易学git了 + diff --git a/dongorigin.txt b/dongorigin.txt new file mode 100644 index 0000000000..dea17ea817 --- /dev/null +++ b/dongorigin.txt @@ -0,0 +1 @@ +非常感谢您的Git与Python教程,仅仅赞助无法表达谢意。如果可能的话,希望可以帮您编写git教程的Android版。 diff --git a/draem0507.txt b/draem0507.txt new file mode 100644 index 0000000000..3f592bf185 --- /dev/null +++ b/draem0507.txt @@ -0,0 +1,5 @@ +thanks a lot. +用过了多年svn,半年前开始使用git来开发管理。 +之前都是使用sourcetree来进行git的管理,极少用到git 命令来完成。 +年前,刚好有时间,偶遇你的这篇教程,很nice。 +对git感兴趣的可以看下这篇文章:http://www.jianshu.com/p/25647b9920b7 diff --git a/drice888888.txt b/drice888888.txt new file mode 100644 index 0000000000..95c22301bf --- /dev/null +++ b/drice888888.txt @@ -0,0 +1 @@ +The first try +2 diff --git a/dupengtao.txt b/dupengtao.txt new file mode 100644 index 0000000000..26c4a12b64 --- /dev/null +++ b/dupengtao.txt @@ -0,0 +1 @@ +thanks for your guide! \ No newline at end of file diff --git a/einverne.md b/einverne.md new file mode 100644 index 0000000000..ec16969720 --- /dev/null +++ b/einverne.md @@ -0,0 +1,14 @@ +git add [-a] +git status +git commit -m "text" +git push origin master +git reset --soft HEAD^ HEAD~2 +git log +git branch +git checkout +git checkout -b "branchname" +git tag -a tagname -m "text" +git merge + + +.gitignore \ No newline at end of file diff --git a/einzbern.txt b/einzbern.txt new file mode 100644 index 0000000000..ebdb9202db --- /dev/null +++ b/einzbern.txt @@ -0,0 +1 @@ +thank you! diff --git a/emma-github-id.txt b/emma-github-id.txt new file mode 100644 index 0000000000..c2d1d8e8f1 --- /dev/null +++ b/emma-github-id.txt @@ -0,0 +1,4 @@ +Hi Michael, +I started to learn git three days ago. Your tutorial is funny and makes it much more easier. Thanks a lot. +Cheers, +Emma diff --git a/ewoshow-github-id.txt b/ewoshow-github-id.txt new file mode 100644 index 0000000000..c44b8bb419 --- /dev/null +++ b/ewoshow-github-id.txt @@ -0,0 +1 @@ +test github \ No newline at end of file diff --git a/feikaifeng.txt b/feikaifeng.txt new file mode 100644 index 0000000000..1459943078 --- /dev/null +++ b/feikaifeng.txt @@ -0,0 +1 @@ +谢谢博主的精彩博文,之前对Git的概念一直很模糊,今天看了您的文章后对Git有了比较明确的认识。谢谢。 diff --git a/ffffff.txt b/ffffff.txt new file mode 100644 index 0000000000..01571fe34d --- /dev/null +++ b/ffffff.txt @@ -0,0 +1 @@ +this is my first file。。。。 diff --git a/fkaking.txt b/fkaking.txt new file mode 100644 index 0000000000..d9d8ec9ad0 --- /dev/null +++ b/fkaking.txt @@ -0,0 +1,3 @@ +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. diff --git a/fkdtz.txt b/fkdtz.txt new file mode 100644 index 0000000000..ad0c0b5bae --- /dev/null +++ b/fkdtz.txt @@ -0,0 +1,2 @@ +my github-id is fkdtz,my name is lisong,my email is +595375808@qq.com diff --git a/fl0wjacky.txt b/fl0wjacky.txt new file mode 100644 index 0000000000..5be6f1d636 --- /dev/null +++ b/fl0wjacky.txt @@ -0,0 +1,3 @@ +hello,Michael Liao. +I teach myself programming from 3 years ago. +Thank for your jobs. diff --git a/flyingpang.py b/flyingpang.py new file mode 100644 index 0000000000..67d10ab86e --- /dev/null +++ b/flyingpang.py @@ -0,0 +1,2 @@ +#coding:utf-8 +Thank you for your git tutorial ! I'm a new programer. diff --git a/freealvin.txt b/freealvin.txt new file mode 100644 index 0000000000..b1c8dd6ef6 --- /dev/null +++ b/freealvin.txt @@ -0,0 +1 @@ +Thanks for sharing. \ No newline at end of file diff --git a/freestyle4568.txt b/freestyle4568.txt new file mode 100644 index 0000000000..93a6ed5559 --- /dev/null +++ b/freestyle4568.txt @@ -0,0 +1,5 @@ +thank you for your kindness and good lessons +i get lots of knowledge from your lessons, learn python and practise again and again +i contact with git through your git lessons, and it is very understandable +now i learn from the git. And i can contribute my strength to our open-source world! +THANK YOU diff --git a/fulinux.txt b/fulinux.txt new file mode 100644 index 0000000000..94904dee16 --- /dev/null +++ b/fulinux.txt @@ -0,0 +1,3 @@ +感谢廖雪峰给我们贡献了如此浅显易懂的git教程。 +写的实在太好了,我已经想身边的同时推荐阅读了。 +再次更新 diff --git a/fushengxu@126.com.txt b/fushengxu@126.com.txt new file mode 100644 index 0000000000..0ae9672b75 --- /dev/null +++ b/fushengxu@126.com.txt @@ -0,0 +1 @@ +楼主写的真的是通俗易懂,学了一天,算是入门了。感觉能把一件东西通俗易懂讲出来,大牛的可能性很大啊!非常感谢楼主,希望楼主能出更好的作品。 \ No newline at end of file diff --git a/galaxybing-demo.txt b/galaxybing-demo.txt new file mode 100644 index 0000000000..58fe02ae1f --- /dev/null +++ b/galaxybing-demo.txt @@ -0,0 +1,3 @@ +本地化版本控制 文件补丁 +Subversion 文件快照 +Git 镜像 \ No newline at end of file diff --git a/gaoming13.php b/gaoming13.php new file mode 100644 index 0000000000..37bc79fe3d --- /dev/null +++ b/gaoming13.php @@ -0,0 +1,2 @@ + $ git unstage test.py + * $ git config --global alias.last 'log -1' + $ git last //显示最近一次的提交 + * git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" + 丧心病狂! 方便地查看git log ... + * 搭建Git服务器 + * 第一步,安装git: + $ sudo apt-get install git + * 第二步,创建一个git用户,用来运行git服务: + $ sudo adduser git + * 第三步,创建证书登录: + 收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个 + * 第四步,初始化Git仓库: + 先选定一个目录作为Git仓库,假定是/srv/sample.git,在/srv目录下输入命令:$ sudo git init --bare sample.git + 把owner改为git : $ sudo chown -R git:git sample.git + * 第五步,禁用shell登录: + 编辑/etc/passwd文件,将git:x:1001:1001:,,,:/home/git:/bin/bash 改为:git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell + * 第六步,克隆远程仓库: + $ git clone git@server:/srv/sample.git diff --git a/genius001.txt b/genius001.txt new file mode 100644 index 0000000000..e8243cfd2b --- /dev/null +++ b/genius001.txt @@ -0,0 +1,2 @@ +your git tutorial is simple and easy to learn. +I will donate your guy for some money:) diff --git a/git-command.md b/git-command.md new file mode 100644 index 0000000000..a4537461d6 --- /dev/null +++ b/git-command.md @@ -0,0 +1,146 @@ +#Git教程 笔记 +> 教程链接:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 + +##创建版本库 ++ `git init`:将当前目录变为Git管理的仓库 ++ `git add `:把文件添加到仓库(stage中) ++ `git commit -m "版本描述"`:把文件按提交到仓库 + +--------------------- +##时光机穿梭 ++ `git status`:显示仓库当前状态 ++ `git diff `:展示文件详细修改内容 +###版本回退 ++ `git log`:显示从最近到最远的提交日志 + + --pretty=oneline:以单行形式显示提交日志 ++ `git reset --hard commit_id`:回退/前进到commit_id指向的版本 ++ `git reset --hard HEAD^`:回退到上一版本 ++ `git log`:查看提交历史 ++ `git reflog`:查看各个版本的commit_id + +###管理修改 ++ git 管理的是修改,而非文件。 ++ 第一次修改 -> git add -> 第二次修改 -> git commit + +###撤销修改 ++ `git checkout -- `:丢弃工作区的修改,返回最近一次add/commit时的文件状态 ++ `git reset HEAD `:丢弃暂存区的修改 + +###删除文件 ++ `git rm `:从版本库中删除文件 + +-------------------- +##远程仓库 + +###添加远程库 +1. 登陆GitHub,“Create a new repository” +2. 添加远程库:`git remote add origin git@github.com:/.git` +3. 推送并关联本地master分支:`git push -u origin master` +4. 提交master分支修改到远程库:`git push origin master` + +###从远程库克隆 ++ `git clone git@github.com:/.git` ++ GitHub支持ssh/https协议 + +--------------------- +##分支管理 + +###创建和合并分支 ++ `git branch `:创建分支 ++ `git branch`:查看分支 ++ `git checkout `:切换分支 ++ `git checkout -b `:创建+切换分支 ++ `git merge `:合并某分支到当前分支 ++ `git branch -d `:删除分支 + +###解决冲突 ++ 当Git无法自动合并分支时,就必须首先解决冲突。解决冲突后,再提交,合并完成 ++ `git log --graph`:看到分支合并图 + +###分支管理策略 +1. `git merge `:`fast forward`模式合并,删除分支,分支信息被丢弃 +2. `git merge --no-ff`:普通模式合并,合并后历史有分支,可通过`git log --graph`看到分支合并记录 + +###Bug分支 ++ `git stash`:储存当前工作现场 ++ `git stash list`:列出所有stash ++ `git stash apply`:恢复最近一次储存的stash ++ `git stash drop`:删除最近一次储存的stash ++ `git stash pop`:恢复+删除最近一次stash ++ `git stash stash@{num}`:恢复指定stash + +###feature分支 ++ `git branch -D `:强行删除没有被合并的分支 + +###多人协作 ++ `git remote -v`:查看远程库的详细信息 ++ `git checkout -b dev origin/dev`:创建远程origin的dev分支到本地 ++ `git branch --set-upstream dev origin/dev`:建立本地分支和远程分支的关联 ++ `git pull`:抓取远程的新提交 ++ `git push origin branch-name`:从本地推送分支 + +--------------------- +##标签管理 ++ 是指向某个commit的指针 ++ 标签不能移动 ++ 创建和删除标签都是瞬间完成的 + +###创建标签 ++ `eg:git tag v1.0` ++ `git tag`:列出所有标签(按字母排序) ++ `git tag `:新建一个标签,默认为HEAD,也可以指定一个commit id ++ `git tag -a -m "description":指定标签信息 ++ `git show `:查看标签信息 + +###操作标签 ++ `git push origin `:推送本地标签到远程库 ++ `git push origin --tags`:推送全部未推送过的本地标签 ++ `git tag -d `:删除本地标签 ++ `git push origin :refs/tags/`:删除远程标签 + +--------------------- +##使用GitHub ++ 自己拥有`Fork`后的仓库的读写权限 ++ 可以推送`pull request`给官方仓库来贡献代码 + +--------------------- +##自定义Git ++ `git config --global color.ui true`:让Git显示颜色 + +###忽略特殊文件 +1. `.gitignore`:配置要忽略的文件 +2. `https://github.com/github/gitignore`:`.gitignore`文件模板 + +###配置别名 ++ 别名是命令的缩写 ++ 例子: + 1. `git config --global alias.st status`:配置status别名为st + 2. `git config --global alias.co checkout`: + 3. `git config --global alias.ci commit`: + 4. `git config --global alias.br branch`: + 5. `git config --global alias.unstage 'reset HEAD'`: + 6. `git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"`: ++ 配置文件: + 1. `.git/config`:仓库的Git配置文件 + 2. `.gitconfig`:当前用户的Git配置文件,放在用户主目录下 + +--------------------- +##搭建Git服务器 +1. 安装git:`sudo apt-get install git` +2. 创建git用户:`sudo adduser git` +3. 创建证书登录:搜集登陆用户公钥(id_rsa.pub)文件,导入`/home/git/.ssh/authorized_keys`文件,一行一个 +4. 初始化Git仓库 + + `sudo git init --bare sample.git` + + `sudo chown R git:git sample.git`:修改裸仓库owner,防止其他用户篡改工作区 +5. 禁用shell登陆(git-shell一登陆就自动退出) + + `vi /etc/passwd` + + `git:x:........:/bin/bash`-->`git:x:......:/usr/bin/git-shell` +6. 克隆远程仓库,本地运行,修改后推送 + + `git clone git@server:/srv/sample.git` + + `git push` +7. 要方便管理公钥,用Gitosis +8. 要像SVN那样变态地控制权限,用Gitolite + +======= + +------------------ diff --git a/git-tool.md b/git-tool.md new file mode 100644 index 0000000000..4933bd4993 --- /dev/null +++ b/git-tool.md @@ -0,0 +1,6 @@ +## 推荐几款chrome上的github插件 +---------- + +- [Octotree](https://github.com/buunguyen/octotree):Browser extensions to display GitHub code in tree format. +- [GistBox](https://chrome.google.com/webstore/detail/gistbox-desktop/pdjgfbgklbmmigkmmdbbhfchdldngkml) :GistBox is the best interface to Github Gists. Organize your snippets with labels. Edit your code. Search by description. All in one speedy app. +- [GistBox Clipper](https://chrome.google.com/webstore/detail/gistbox-clipper/cejmhmbmafamjegaebkjhnckhepgmido):GistBox Clipper is the companion extension to GistBox, the most beautiful way to organize code snippets. It allows a user to create a GitHub Gist from any page on the web. diff --git a/git-vi-test b/git-vi-test new file mode 100644 index 0000000000..2994d226a9 --- /dev/null +++ b/git-vi-test @@ -0,0 +1 @@ +the use of git is interesting diff --git a/git@github.com-dangweili.txt b/git@github.com-dangweili.txt new file mode 100644 index 0000000000..9553eb124c --- /dev/null +++ b/git@github.com-dangweili.txt @@ -0,0 +1 @@ +Thank you for your work ! \ No newline at end of file diff --git a/git_learning_wrote b/git_learning_wrote new file mode 100644 index 0000000000..2a736c40dd --- /dev/null +++ b/git_learning_wrote @@ -0,0 +1,10 @@ +1, git inti +2, touch readme.txt +3, git status +4, git add readme.txt +5, git status +6, git commit -m "add readme.txt file" +7, repeat the abvoe steps to create LICENSE file +8, git remote add original git@github.com:andyChenHuaYing/learngit.git +9, git remote push -u origin master +0, visit github to observe the repository's change. diff --git a/git_note.md b/git_note.md new file mode 100644 index 0000000000..30cc14a3b2 --- /dev/null +++ b/git_note.md @@ -0,0 +1,111 @@ +# Git与GitHub + +标签(空格分隔): ReadingNote + +[toc] + +----------------------- +## 常用命令 +- 开始时,克隆 +``` +$ git clone git@github.com:yourname/resp.git # 仅master +$ git checkout -b dev origin/dev # 新建并克隆分支 +``` +- 查看状态 +``` +$ git status +$ git diff #add之前 +$ git log [--pretty=oneline] +$ git log -p -1 # 查看最近一次提交的修改 +$ git reflog # 查看使用过的命令 +``` +- 完成后,add与commit +``` +$ git add . +$ git commit -m "It's the comment." +``` +- 版本回退 +``` +$ git reset --hard HEAD^^ # 回退两个版本 +$ git reset --hard HEAD~100 # 回退100个版本 +``` +- 撤销修改 +``` +$ git checkout -- # 撤销工作区中的修改 +$ git reset HEAD # 撤销add +``` +- 添加标签(release) +``` +$ git tag v0.1 [0f50c4] #为[0f50c4]设置标签v0.1 +$ git tag # 查看已有标签 +$ git show v0.1 # 查看v0.1 +$ git push origin --tags # 推送所有标签 +$ git tag -d v0.1 # 删除标签 +``` +-------------------------- +## 分支管理 +> git的分支管理,是文件指针的变化;git鼓励使用分支 + +### 基本操作 +- 创建分支 +``` +$ git checkout -b dev # 创建分支dev +``` +- 切换分支 +``` +$ git checkout dev # 切换到dev +``` +- 查看分支 +``` +$ git branch +``` +- 合并分支 +``` +$ git merge [--no-ff -m "merge with no-ff"] dev +``` +- 删除分支 +``` +$ git branch -d dev +``` +- 保存现场 +``` +$ git stash +$ git stash pop +``` +### 解决冲突 +- 有冲突时,无法合并,需要手工解决冲突 +- 通过`git status`查看冲突的文件 +- 打开冲突的文件,git已经标记了冲突的位置 + +###多人协作 +> 出现冲突时,先pull到本地,合并后再push + +- 远程提交 +``` +$ git push [-u] origin master # 第一次使用需要[-u] +``` +- 建立关联 +``` +$ git branch --set-upstream dev origin/dev +``` +- 本地同步 +``` +$ git pull +``` +-------------------------- +## 第一次使用的基本配置 +- 产生`密钥` +``` +$ ssh-keygen -t rsa -C "your_email@youremail.com" +``` +- 在github中注册`公钥`(`~/.ssh/id_rsa.pub`) +- 设置`username`与`email` +``` +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +``` +----------------------- +## 参考资料 +1. [廖雪峰的官方网站 - Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000) +1. [Wuyuan's Blog](http://wuyuans.com/2012/05/github-simple-tutorial/) +1. [快乐&&平凡 - CSDN.NET](http://blog.csdn.net/wh_19910525/article/details/8128916) diff --git a/git_test.txt b/git_test.txt new file mode 100644 index 0000000000..8138d0d7e9 --- /dev/null +++ b/git_test.txt @@ -0,0 +1 @@ +看了大神的git教程,来试验一下pull request!>_< \ No newline at end of file diff --git a/github_id b/github_id new file mode 100644 index 0000000000..cdeec60f4e --- /dev/null +++ b/github_id @@ -0,0 +1 @@ +..... diff --git a/githubpassok748.txt b/githubpassok748.txt new file mode 100644 index 0000000000..0d84f7210c --- /dev/null +++ b/githubpassok748.txt @@ -0,0 +1,5 @@ +非常感谢大神让我入门Git! + +内容通俗易懂,堪比《图灵》系列作者写作水准! + +BZW: 我也是业务产品经理HOHO~ \ No newline at end of file diff --git a/glivia.txt b/glivia.txt new file mode 100644 index 0000000000..b47ee294e3 --- /dev/null +++ b/glivia.txt @@ -0,0 +1 @@ +It's really good! Thanks! diff --git a/gnoygn1.txt b/gnoygn1.txt new file mode 100644 index 0000000000..7dc354d0d4 --- /dev/null +++ b/gnoygn1.txt @@ -0,0 +1 @@ +非常好的git教材,按着事例做学习的很快,多谢廖老师! diff --git a/gordon-learngit.md b/gordon-learngit.md new file mode 100644 index 0000000000..973b3e10a2 --- /dev/null +++ b/gordon-learngit.md @@ -0,0 +1 @@ +gordon fork file diff --git a/gouchao2008@qq.com b/gouchao2008@qq.com new file mode 100644 index 0000000000..d25ed3adb1 --- /dev/null +++ b/gouchao2008@qq.com @@ -0,0 +1,2 @@ +thanks +i like this course diff --git a/gqtc.txt b/gqtc.txt new file mode 100644 index 0000000000..13f24137ec --- /dev/null +++ b/gqtc.txt @@ -0,0 +1,2 @@ +非常感谢您的git教程,要是赞助方式支持网银的话,我一定会赞助的。 +thank you very much! diff --git a/gratitude.txt b/gratitude.txt new file mode 100644 index 0000000000..c3a38a780a --- /dev/null +++ b/gratitude.txt @@ -0,0 +1 @@ +thank you very much!!! \ No newline at end of file diff --git a/gulisha.txt b/gulisha.txt new file mode 100644 index 0000000000..ccd790032c --- /dev/null +++ b/gulisha.txt @@ -0,0 +1 @@ +thank you ! \ No newline at end of file diff --git a/guoyalun.md b/guoyalun.md new file mode 100644 index 0000000000..757fbf97dd --- /dev/null +++ b/guoyalun.md @@ -0,0 +1,3 @@ +感谢给我们贡献了如此浅显易懂的git教程。 +真正的感觉自己git 可以轻松入门了! + diff --git a/guoziali.txt b/guoziali.txt new file mode 100644 index 0000000000..101876b1c2 --- /dev/null +++ b/guoziali.txt @@ -0,0 +1,2 @@ +test pull request + thanks for you help diff --git a/guzhuyi b/guzhuyi new file mode 100644 index 0000000000..270c611ee7 --- /dev/null +++ b/guzhuyi @@ -0,0 +1 @@ +hello, world! diff --git a/gyb.txt b/gyb.txt new file mode 100644 index 0000000000..819cc44976 --- /dev/null +++ b/gyb.txt @@ -0,0 +1 @@ +haha \ No newline at end of file diff --git a/haokee.txt b/haokee.txt new file mode 100644 index 0000000000..8ca0dd4b7c --- /dev/null +++ b/haokee.txt @@ -0,0 +1 @@ +我倒是觉得git的学习起点是比较高的,但是按照作者的网页一点点敲,相信会有意想不到的收获,顶作者还有他的主页 http://www.liaoxuefeng.com。做的很棒,加油!!! diff --git a/haolidong.txt b/haolidong.txt new file mode 100644 index 0000000000..4407009d0d --- /dev/null +++ b/haolidong.txt @@ -0,0 +1 @@ +这是来自一个git新手的推送,测试教程中所说的fork,clone,pull request的操作方法 diff --git a/hds2007.txt b/hds2007.txt new file mode 100644 index 0000000000..877f194eb6 --- /dev/null +++ b/hds2007.txt @@ -0,0 +1 @@ +hds2007 于2015/7/8 添加。 \ No newline at end of file diff --git a/hejy12.txt b/hejy12.txt new file mode 100644 index 0000000000..9ff3882359 --- /dev/null +++ b/hejy12.txt @@ -0,0 +1 @@ +Hello, git ! diff --git a/hello b/hello new file mode 100644 index 0000000000..5e196d2ef1 --- /dev/null +++ b/hello @@ -0,0 +1,7 @@ +public class main +{ + public static void main(String [] args) + { + System.out.println("hello world!"); + } +} diff --git a/hello world b/hello world new file mode 100644 index 0000000000..a0409f6af7 --- /dev/null +++ b/hello world @@ -0,0 +1 @@ +中午好啊...... diff --git a/hello-world pull request b/hello-world pull request new file mode 100644 index 0000000000..cab0f0eb82 --- /dev/null +++ b/hello-world pull request @@ -0,0 +1,4 @@ + +This is the first pull request called hello-world ! + +Thanks! diff --git a/helloTeacherLiao.txt b/helloTeacherLiao.txt new file mode 100644 index 0000000000..53e27a6be7 --- /dev/null +++ b/helloTeacherLiao.txt @@ -0,0 +1,4 @@ +感谢廖老师精彩的教程! +it界多一些廖老师这样的无私奉献者,世界将变成美好的人间! +哈哈哈 +Thanks a lot. diff --git a/helloToXueFeng.txt b/helloToXueFeng.txt new file mode 100644 index 0000000000..ce246f0c31 --- /dev/null +++ b/helloToXueFeng.txt @@ -0,0 +1,7 @@ +My feeling of learning MichaelLiao's Lesson: + +Thanks for your asesome Git Lesson. It help us open the eyes to the open source project world. I use two day's time to learn how to use git through your leasson. I really like your word of your Git Lesson and it's so easy to understand. + +All in all, I hope you have a better life and write more useful and high-qualified lesson. + +Thank you again. diff --git a/hellogit.txt b/hellogit.txt new file mode 100644 index 0000000000..404a44e60e --- /dev/null +++ b/hellogit.txt @@ -0,0 +1 @@ +hello,git,you are my friend. diff --git a/helloworld b/helloworld new file mode 100644 index 0000000000..5d308e1d06 --- /dev/null +++ b/helloworld @@ -0,0 +1 @@ +aaaa diff --git a/henryliyunfeng-git.txt b/henryliyunfeng-git.txt new file mode 100644 index 0000000000..b48a15491e --- /dev/null +++ b/henryliyunfeng-git.txt @@ -0,0 +1 @@ +hello ,你好,i love you \ No newline at end of file diff --git a/henulwj.txt b/henulwj.txt new file mode 100644 index 0000000000..4f9927370a --- /dev/null +++ b/henulwj.txt @@ -0,0 +1,2 @@ +Thank you very much! +I have learned how to handle git. diff --git a/hexianjie.txt b/hexianjie.txt new file mode 100644 index 0000000000..0affa86004 --- /dev/null +++ b/hexianjie.txt @@ -0,0 +1,2 @@ +感谢老师的教程, +希望老师越来越好! diff --git a/hezhping.txt b/hezhping.txt new file mode 100644 index 0000000000..303d5c2307 --- /dev/null +++ b/hezhping.txt @@ -0,0 +1,4 @@ +廖老师: + 您好! + 首先感谢你的无私奉献,我先后看过你的python教程和Git教程,受益匪浅。 + diff --git a/hitoy.txt b/hitoy.txt new file mode 100644 index 0000000000..8630e4fe74 --- /dev/null +++ b/hitoy.txt @@ -0,0 +1,2 @@ +This is hito from http://www.hitoy.org +This for liaoxuefeng's git course diff --git a/hjc1702.txt b/hjc1702.txt new file mode 100644 index 0000000000..18141e0a3c --- /dev/null +++ b/hjc1702.txt @@ -0,0 +1,2 @@ +按照您的git教程一步步使用,感觉非常好。非常清晰. +谢谢您的教程~ diff --git a/hmlv b/hmlv new file mode 100644 index 0000000000..b94bc9c3cf --- /dev/null +++ b/hmlv @@ -0,0 +1,2 @@ +hello michaelliao: + thank you very much. diff --git a/hongqi.txt b/hongqi.txt new file mode 100644 index 0000000000..0affa86004 --- /dev/null +++ b/hongqi.txt @@ -0,0 +1,2 @@ +感谢老师的教程, +希望老师越来越好! diff --git a/huang-feature.txt b/huang-feature.txt new file mode 100644 index 0000000000..74c2be3d2e --- /dev/null +++ b/huang-feature.txt @@ -0,0 +1 @@ +I am Bob Huang,Nice to meet you! diff --git a/huangyue5207.txt b/huangyue5207.txt new file mode 100644 index 0000000000..914f35289e --- /dev/null +++ b/huangyue5207.txt @@ -0,0 +1 @@ +it's a very good toturial of git,it's very useful for me.thank you! diff --git a/hustyjy@qq.com.txt b/hustyjy@qq.com.txt new file mode 100644 index 0000000000..0f8ff38c23 --- /dev/null +++ b/hustyjy@qq.com.txt @@ -0,0 +1 @@ +教程很强大,谢谢。 diff --git a/hzdavid2013@gmail.txt b/hzdavid2013@gmail.txt new file mode 100644 index 0000000000..f156500d0f --- /dev/null +++ b/hzdavid2013@gmail.txt @@ -0,0 +1,2 @@ +thand you very much . +you article is very good. diff --git a/hzlu-github.py b/hzlu-github.py new file mode 100644 index 0000000000..5270d53d65 --- /dev/null +++ b/hzlu-github.py @@ -0,0 +1 @@ +print "hello, thank you for your GIT Tutorial." \ No newline at end of file diff --git a/hztgcl1986.txt b/hztgcl1986.txt new file mode 100644 index 0000000000..a2960a905f --- /dev/null +++ b/hztgcl1986.txt @@ -0,0 +1 @@ +Git教程非常棒!!! diff --git a/iinsonia.txt b/iinsonia.txt new file mode 100644 index 0000000000..a396b6b8fb --- /dev/null +++ b/iinsonia.txt @@ -0,0 +1 @@ +thanks for your lesson! diff --git a/iwang.txt b/iwang.txt new file mode 100644 index 0000000000..dfc89baa65 --- /dev/null +++ b/iwang.txt @@ -0,0 +1,7 @@ +Mr.Liao: + +Your tuition is the best Git_for_freshman that I have read ever. + +Thanks a lot. + +from iwang@tencent.com diff --git a/jackchan0419.txt b/jackchan0419.txt new file mode 100644 index 0000000000..03d9a27b42 --- /dev/null +++ b/jackchan0419.txt @@ -0,0 +1 @@ +Git pull test. diff --git a/jackie.txt b/jackie.txt new file mode 100644 index 0000000000..1b2b093a1f --- /dev/null +++ b/jackie.txt @@ -0,0 +1 @@ +pull request test diff --git a/jacks808.txt b/jacks808.txt new file mode 100644 index 0000000000..58b0971f0c --- /dev/null +++ b/jacks808.txt @@ -0,0 +1,11 @@ +this is a git learn note from keen (find me on git:github.com/jacks808) +1.git add [file name] +2.git commit -m "msg" +3.git push origin dev +4.git checkout dev-keen : create a new branch and switch to it +5.git checkout dev : switch to branch dev +6.git merge dev-keen : merge dev-keen branch to branch in use(now is dev) + +THANK FOR YOU COURSE! + +YOU CAN FIND ME AT jacks808@163.com diff --git a/jaminzhang.txt b/jaminzhang.txt new file mode 100644 index 0000000000..c7c299e770 --- /dev/null +++ b/jaminzhang.txt @@ -0,0 +1,3 @@ +Thank you very much, Teacher Liao. +Your git course explains the profound in simple terms. +I like it. diff --git a/jason.txt b/jason.txt new file mode 100644 index 0000000000..ebdb9202db --- /dev/null +++ b/jason.txt @@ -0,0 +1 @@ +thank you! diff --git a/javaSwing.txt b/javaSwing.txt new file mode 100644 index 0000000000..2fc78e9feb --- /dev/null +++ b/javaSwing.txt @@ -0,0 +1 @@ +This is javaSwing pull request txt! Only to learn git! diff --git a/jiangkui.txt b/jiangkui.txt new file mode 100644 index 0000000000..89937b38dd --- /dev/null +++ b/jiangkui.txt @@ -0,0 +1,102 @@ +貌似都用英语表达谢意。。。 英语太菜了。。。 +花了大概3天左右的时间练习完这个教程,廖老师写的教程确实不错。。。 +点个赞 + +顺便带上一个粗糙的笔记。 用的马克飞象,跟markdown差不多。 + +============================================================ + + +#《Git 教程》 廖雪峰 + +[原文地址][1] + +**注意事项** : +- **中文目录**:如果你使用Windows系统,为了避免遇到各种莫名其妙的问题,请确保目录名(包括父目录)不包含中文。 +- **管理范围**:所有的版本控制系统,其实只能跟踪文本文件的改动,比如 TXT 文件,网页,所有的程序代码等,Git也不例外。而图片、视频这些二进制文件,没法跟踪文件的变化,只能把二进制文件每次改动串起来。 Microsoft 的 Word 格式是二进制格式。所以也没法弄。 +- **其他**:千万不要使用 Windows 自带的记事本编辑任何文本文件,原因是 Microsoft 开发记事本的团队,在每个文件开头添加了 0xefbbbf(十六进制)的字符。 +- **分支管理策略**:Git 默认会用 `Fast forward` 模式,这种模式下,删除分之后,会丢掉分支信息。禁用 `Fast forward`模式,就能看到分支信息。`git merge --no-ff -m "说明" <分支名称>` `--no-ff` 表示禁用 `Fast forward`。 + +------------------------------ + +[TOC] + +##Git的优势 +- 在本地工作完全不用考虑远程库的存在,svn在没有联网时是拒绝干活的。有网络的时候,再把本地库提交推送以下就完成了同步。 + +##Linux命令 +- mkdir:创建目录 +- cd: +- pwd:显示当前目录 + +##Git 命令 + +| 命令 | 说明 | +| :------ | :-------------- | +|git init | 初始化 | +|git add `` | 添加文件到仓库 `文件必须在仓库目录下,可反复多次使用,添加多个文件` | +|git commit -m '' | 本次提交的说明 | +|git status | 工作区的状态 | +|git diff HEAD -- `` | 查看工作区与版本库里最新版本的区别`HEAD表示当前版本` | +|git reset --hard commit_id | 回退到历史版本 | +|git log | 查看`提交`历史 | +|git reflog | 查看`命令`历史 | +|git checkout -- `` | 丢弃工作区的修改 | +|git rm `` | 删除 | +||| +|git push | 把当前分支`master`推送到远程仓库 | +|git push -u origin master | 第一次推送 master 分支的所有内容 | +|git push origin `【tagname | --tags】 后者表示推送所有标签`) | 推送标签到远程库 | +|git push origin :refs/tags/`` | 可以删除一个远程标签 | +||| +|git remote add ...`百度` | 关联远程库 | +|git lone `https://github.com/jiangkui/gitskills2`| 克隆仓库到本地,Git支持多种协议,包括`https`,但通过 `ssh` 支持的原生 `git`协议速度最快| +||| +|git branch | 查看分支 | +|git branch `` | 创建分支 | +|git branch -d `` | 删除分支 | +|git branch -D `` | 强行删除没有合并过的分支 | +|git branch --set-upstream `本地分支名称` origin/`远程分支名称` | 建立本地分支和远程分支的关联 | +||| +|git checkout `` | 切换分支 | +|git checkout -b `` | 创建+切换分支 | +|git checkout -b `本地分支名称` origin/`远程分支名称` | 在本地创建和远程对应的分支(`本地分支名称与远程分支名称最好一致`) | +|git merge `` | 合并某分支到当前分支 | +|git log --graph | 看到分支合并图 | +|git stash | 存储当前修改的内容 | +|git stash list | 查看存储的工作现场 list | +|git stash pop | 取出并删除存储的第一个内容 | +|git stash apply | 恢复存储的内容但不删除 | +|git remote -v | 查看远程库信息 | +|git push origin `分支名称` | 从本地库推送分支 | +|git pull | 抓取远程的新提交 | +|git tag `` `[版本号,默认 HEAD]` | 用户新建一个标签 | +|git tag -a `` -m `blablabla` | 指定标签信息 | +|git tag | 查看所有标签 | +|git tag -d v0.1| 删除标签| + + + +##名词概念 +**工作区**:git项目里,电脑能看到的目录(文件夹)。 +**版本库**:工作区有一个隐藏目录`.git`,这个不算工作区,是Git 的版本库。 +git 的版本库里存了很多东西,其中最重要的就是 stage(或者叫 index)的暂存区,还有Git 为我们自动创建的第一个分支`master`,以及指向`master`的第一个指针叫`HEAD`。 +![Alt text](./1428395768401.png) + +在向Git 版本库里添加的时候,分两步: +第一步用`git add`把文件添加进去,实际上把文件修改添加到暂存区; +第二步用`git commit`提交,就是把暂存区的所有内容提交到当前分支。 + +`暂存区是Git 非常重要的概念,弄明白了暂存区,就弄明白了Tig的都很多操作到底干了什么。` + +每次修改,如果不add到暂存区,那就不会加入到 `commit`中。 + + +[1]:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 + + + +============================================================ + + + jiangkui 20115-04-09 \ No newline at end of file diff --git a/jiucai.txt b/jiucai.txt new file mode 100644 index 0000000000..78a4a7a966 --- /dev/null +++ b/jiucai.txt @@ -0,0 +1,4 @@ +the best profit of git is more branch will not add repository file size ,just record changes and index. + + +-- wrote by jiucai at 2014-09-17 diff --git a/johnleo.txt b/johnleo.txt new file mode 100644 index 0000000000..259079a5b1 --- /dev/null +++ b/johnleo.txt @@ -0,0 +1 @@ +Thank you for your tutorial. diff --git a/junfengwang.txt b/junfengwang.txt new file mode 100644 index 0000000000..0fddcc0fde --- /dev/null +++ b/junfengwang.txt @@ -0,0 +1 @@ +谢谢峰的教程 马上就要看完git教程 python也看了一半了 希望再出点其他技术教程,如 node.js, 谢谢 \ No newline at end of file diff --git a/justlearn.txt b/justlearn.txt new file mode 100644 index 0000000000..07d918fcd1 --- /dev/null +++ b/justlearn.txt @@ -0,0 +1 @@ +long long ago , i try my best to learn git by one book ,it is too heavy and difficult for me to learn . and a month later ,i forgot what i learned .util now ,i really like teacher liao,i learned so much from you.thank you! diff --git a/justsayhi.txt b/justsayhi.txt new file mode 100644 index 0000000000..cfbd95b142 --- /dev/null +++ b/justsayhi.txt @@ -0,0 +1 @@ +我就四 试一试。。哈哈 谢谢 liaolaoshi \ No newline at end of file diff --git a/jyc.txt b/jyc.txt new file mode 100644 index 0000000000..bf0f4d2bb9 --- /dev/null +++ b/jyc.txt @@ -0,0 +1 @@ +i am jyc,thank you very much diff --git a/k0becheng-1.txt b/k0becheng-1.txt new file mode 100644 index 0000000000..51b885a4b6 --- /dev/null +++ b/k0becheng-1.txt @@ -0,0 +1,2 @@ +昨天下午刚开始看您的教程,果然比pro git更适合我们这些个刚入门的用户呢! +暂时对git的使用还不是太熟悉,等熟悉了有比较好的理解我会通过博客的方式和大家共享。 \ No newline at end of file diff --git a/kid b/kid new file mode 100644 index 0000000000..b6ca084731 --- /dev/null +++ b/kid @@ -0,0 +1 @@ +kid is a testfile diff --git a/kingone-id.txt b/kingone-id.txt new file mode 100644 index 0000000000..5dde773b1f --- /dev/null +++ b/kingone-id.txt @@ -0,0 +1 @@ +I like Git very much,and I want to improve my Git Skills as soon as possible is I want to do now. diff --git a/km_test.txt b/km_test.txt new file mode 100644 index 0000000000..05e69ab056 --- /dev/null +++ b/km_test.txt @@ -0,0 +1 @@ +testing pull. Thx for liaoxuefeng \ No newline at end of file diff --git a/koala.txt b/koala.txt new file mode 100644 index 0000000000..af6dd70c47 --- /dev/null +++ b/koala.txt @@ -0,0 +1,2 @@ +im koala +Thanks diff --git a/ksir.txt b/ksir.txt new file mode 100644 index 0000000000..235b037f8f --- /dev/null +++ b/ksir.txt @@ -0,0 +1,3 @@ +很好的学习教程,生动形象 +利用下班的时间很快就学会上手使用了。 +感谢作者! diff --git a/lalaticao.txt b/lalaticao.txt new file mode 100644 index 0000000000..110760acc9 --- /dev/null +++ b/lalaticao.txt @@ -0,0 +1 @@ +Merci beaucoup! \ No newline at end of file diff --git a/lcjingdi@gmail.com b/lcjingdi@gmail.com new file mode 100644 index 0000000000..d71e468d9e --- /dev/null +++ b/lcjingdi@gmail.com @@ -0,0 +1 @@ +你的教程比较浅显易懂很受用谢谢!!! diff --git a/learn_git.txt b/learn_git.txt new file mode 100644 index 0000000000..75fce32735 --- /dev/null +++ b/learn_git.txt @@ -0,0 +1,3 @@ +this is a request pull + +on GITHUB diff --git a/learn_git_thx.txt b/learn_git_thx.txt new file mode 100644 index 0000000000..573f761af4 --- /dev/null +++ b/learn_git_thx.txt @@ -0,0 +1 @@ +thanks for your blog diff --git a/learn_manual.txt b/learn_manual.txt new file mode 100644 index 0000000000..4c170e731f --- /dev/null +++ b/learn_manual.txt @@ -0,0 +1,175 @@ + +0.安装完成后,还需要最后一步设置,在命令行输入: + +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +因为Git是分布式版本控制系统,所以,每个机器都必须自报家门:你的名字和Email地址。你也许会担心,如果有人故意冒充别人怎么办?这个不必担心,首先我们相信大家都是善良无知的群众,其次,真的有冒充的也是有办法可查的。 + +1.git status +是对比 版本库中的 branch :master 中的文件 和 working directory中的文件 + +2.若一样 : + $ git status + # On branch master + to commit (working directory clean + 若不一样: + 对比是否提交到index:stage中 暂时区 + 此时可以将working directory 中的文件用命令 git checkout 和标准的master中的一样--变化的是working directory + + 提交add 到stage中 则提示 是否commit + 此时 可以用 git reset HEAD to unstage + + +3.为什么Git比其他版本控制系统设计得优秀, + 因为Git跟踪并管理的是修改,而非文件。 + “git commit”只负责把暂存区的修改提交了 + +4."git checkout -- ..." to discard changes in working directory) + 是让这个文件回到最近一次git commit或git add时的状态。 + + +5.git reset命令既可以回退版本,也可以把暂存区的修改回退到工作区 + + git checkout -- readme.txt + git reset HEAD readme.txt HEAD原来在working directory处,当git add后 ,HEAD指向stage + git reset --hard HEAD^ HEAD在commit后指向master + +6.你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要一点设置: + + $ ssh-keygen -t rsa -C "youremail@example.com" + -t type Specify type of key to create. + -C comment Provide new comment. + +7.push an existing repository from the command line + + git remote add origin git@github.com:fergusj/LearnGit.git + git push -u origin master + + 从现在起,只要本地作了提交,就可以通过命令: + $ git push origin master + + 克隆别人git + git clone git@github.com:michaelliao/gitskills.git + +8.HEAD确定当前分支,master指向最新的提交 +每次只对HEAD指向的指针dev做操作(修改),可以两个指针合并————平行空间相遇了。 + +9.Git鼓励大量使用分支: + + 查看分支:git branch + + 创建分支:git branch name + + 切换分支:git checkout name + + 创建+切换分支:git checkout -b name + + 合并某分支到当前分支:git merge name + + 删除分支:git branch -d name + +10. $ git diff readme.txt + + +11. 参数的git log也可以看到分支的合并情况: + +$ git log --graph --pretty=oneline --abbrev-commit + + +12.准备合并dev分支,请注意--no-ff参数,表示禁用“Fast forward”: +$ git merge --no-ff -m "merge with no-ff" dev +因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 +合并后,我们用git log看看分支历史: +$ git log --graph --pretty=oneline --abbrev-commit + +13.在实际开发中,我们应该按照几个基本原则进行分支管理: +首先,master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活; +那在哪干活呢? + +干活都在dev分支上,也就是说,dev分支是不稳定的,到某个时候,比如1.0版本发布时,再把dev分支合并到master上,在master分支发布1.0版本; +你和你的小伙伴们每个人都在dev分支上干活,每个人都有自己的分支,时不时地往dev分支上合并就可以了。 +所以,团队合作的分支看起来就像这样: + +14.stash临时解决主线上bug ,暂存我当前工作分支,在主线上新建issue-101来解决,后恢复现场 + +15.Feature分支 软件开发中,总有无穷无尽的新的功能要$ git branch -d feature-vulcan + +error: The branch 'feature-vulcan' is not fully merged. +If you are sure you want to delete it, run 'git branch -D feature-vulcan'. +销毁失败。Git友情提醒,feature-vulcan分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用命令git branch -D feature-vulcan不断添加进来。 + + +16.并不是一定要把本地分支往远程推送,那么,哪些分支需要推送,哪些不需要呢? + +master分支是主分支,因此要时刻与远程同步; + +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + + + +17.origin 远程仓库的默认名称 +master 本地分支 和远程 分支 + + + + +18. +他用这个命令创建本地dev分支: + +$ git checkout -b dev origin/dev + + + +19. +多人协作的工作模式通常是这样: + +首先,可以试图用git push origin branch-name推送自己的修改; + +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +如果合并有冲突,则解决冲突,并在本地提交; + +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单 + +20.git pull 相当于更新本地的分支和github中的分支文件校准 +$ git push origin dev 相当于 推送本地分支 到github中 +Everything up-to-date + +21.标签也是版本库的一个快照。 + + + +22. git tag v1.0 当前处建立标签 + git tag v0.1 abc001 在git log 信息commit id的地方 + git tag 查询所有标签 + 默认的是按照字母排序 + git show v0.1 显示详细信息 + git tag -d v0.1 删除 + git push origin tagname 默认标签是本地的,用这个命令 推送到远程 + git push origin --tags 一次性推送所有tag + +删除已经push到origin中标签 +git tag -d v0.9 +git push origin :refs/tags/v0.9 + + +命令git push origin tagname可以推送一个本地标签; + +命令git push origin --tags可以推送全部未推送过的本地标签; + +命令git tag -d tagname可以删除一个本地标签; + +命令git push origin :refs/tags/tagname可以删除一个远程标签。 + + + + + \ No newline at end of file diff --git a/learn_tezika b/learn_tezika new file mode 100644 index 0000000000..ca56fd46fc --- /dev/null +++ b/learn_tezika @@ -0,0 +1 @@ +Thanks for teacher liao!!!:-) diff --git a/learngit.txt b/learngit.txt new file mode 100644 index 0000000000..b2fddadcf3 --- /dev/null +++ b/learngit.txt @@ -0,0 +1,3 @@ +thx, miu + +i will learn git \ No newline at end of file diff --git a/learngit/.DS_Store b/learngit/.DS_Store new file mode 100644 index 0000000000..d95da94821 Binary files /dev/null and b/learngit/.DS_Store differ diff --git a/learngit/.gitignore b/learngit/.gitignore new file mode 100644 index 0000000000..211779b153 --- /dev/null +++ b/learngit/.gitignore @@ -0,0 +1,19 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ +asdasd +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Project file +*.project +*.pydevproject +asdasd + +my_git diff --git a/learngit/.xlshlr_git command.txt b/learngit/.xlshlr_git command.txt new file mode 100644 index 0000000000..80608eafa8 --- /dev/null +++ b/learngit/.xlshlr_git command.txt @@ -0,0 +1,62 @@ +$ git config --global user.name "xlshlr" +$ git config --global user.email "xlshlr@163.com" +$ git init +$ git add readme.txt +$ git add file2.txt file3.txt +$ git commit -m "wrote a readme file" +$ git status +$ git diff readme.txt +$ git log --pretty=oneline +$ git reset --hard HEAD^ +$ git reset --hard 3628164 +$ git reflog +$ git diff HEAD -- readme.txt +$ git checkout -- readme.txt +$ git rm test.txt +$ git remote add origin https://github.com/xlshlr/firstblood.git +$ git push -u origin master + +$ git checkout -b dev +$ git branch dev +$ git checkout dev +$ git checkout master +$ git merge dev +$ git branch -d dev +$ git branch -D feature-vulcan + +git log --graph +$ git merge --no-ff -m "merge with no-ff" dev +$ git log --graph --pretty=oneline --abbrev-commit +$ git stash +$ git stash list +git stash apply +git stash drop +$ git stash pop +$ git stash apply stash@{0} +$ git push origin dev:dev // 提交本地dev分支作为远程的dev分支 + +$ git push origin :dev // 刚提交到远程的dev将被删除,但是本地还会保存的,不用担心 +$ git push origin dev +$ git remote +$ git branch --set-upstream dev origin/dev +$ git tag v1.0 +$ git tag +$ git tag v0.9 6224937 +$ git show v0.9 +$ git tag -a v0.1 -m "version 0.1 released" 3628164 +$ git tag -s v0.2 -m "signed version 0.2 released" fec145a +$ git push origin v1.0 +$ git push origin --tags +$ git tag -d v0.9 +$ git push origin :refs/tags/v0.9 + + + + + + + + + + +git push -u origin master \ No newline at end of file diff --git a/learngit/1024.cpp b/learngit/1024.cpp new file mode 100644 index 0000000000..2c590d21c0 --- /dev/null +++ b/learngit/1024.cpp @@ -0,0 +1,5 @@ +#include +int main(){ + std::cout << "1024" << std::endl; + return 0; +} diff --git a/learngit/2 b/learngit/2 new file mode 100644 index 0000000000..cfbacb455f --- /dev/null +++ b/learngit/2 @@ -0,0 +1,4 @@ +thanks +for your help + + diff --git a/learngit/20150427add.txt b/learngit/20150427add.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/learngit/521xueweihan.txt b/learngit/521xueweihan.txt new file mode 100644 index 0000000000..45a563e330 --- /dev/null +++ b/learngit/521xueweihan.txt @@ -0,0 +1,2 @@ +最后一个测!let‘go! +再测试一次 \ No newline at end of file diff --git a/learngit/Aragron.txt b/learngit/Aragron.txt new file mode 100644 index 0000000000..c0a5b40722 --- /dev/null +++ b/learngit/Aragron.txt @@ -0,0 +1,4 @@ +I am really excited! +I can see soo high quality material in Internet! +Really Thankyou , liao! +It is amazing!!! \ No newline at end of file diff --git a/learngit/AyumuAkira.txt b/learngit/AyumuAkira.txt new file mode 100644 index 0000000000..5814c2498a --- /dev/null +++ b/learngit/AyumuAkira.txt @@ -0,0 +1 @@ +Thanks for sharing very much. \ No newline at end of file diff --git a/learngit/BLUE-V.txt b/learngit/BLUE-V.txt new file mode 100644 index 0000000000..49cd706aa1 --- /dev/null +++ b/learngit/BLUE-V.txt @@ -0,0 +1,2 @@ +thank you liao + - from 白兰度 diff --git a/learngit/Best.txt b/learngit/Best.txt new file mode 100644 index 0000000000..6d5b02179a --- /dev/null +++ b/learngit/Best.txt @@ -0,0 +1,3 @@ +"Helo, word" + + thank you!!! diff --git a/learngit/BlueIceQ.txt b/learngit/BlueIceQ.txt new file mode 100644 index 0000000000..16165e28b6 --- /dev/null +++ b/learngit/BlueIceQ.txt @@ -0,0 +1,2 @@ +廖大大的教程很接地气,很实用,简单易学,容易上手. +希望关于java1.8的教程也快快能够看到. diff --git a/learngit/CTextBox.cs b/learngit/CTextBox.cs new file mode 100644 index 0000000000..2f4da125fd --- /dev/null +++ b/learngit/CTextBox.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Linq.Expressions; +using Zwj.TEMS.Common; + + +namespace TEMS.Controls +{ + /// + /// 文本框 + /// Author:Wheeky + /// Url:www.zuowenjun.cn + /// + public partial class CTextBox : UserControl,IZwjDefControl + { + [Description("当点击按钮时触发该事件")] + public event EventHandler OnOpen; + + [Description("当值改变时触发该事件")] + public event EventHandler OnValueChange; + + public CTextBox() + { + InitializeComponent(); + this.DispalyOpenButton = false; + textBox1.TextChanged += delegate { RaiseValueChange(); }; + } + + private void RaiseValueChange() + { + if (this.OnValueChange!=null) + { + this.OnValueChange(this, null); + } + } + + [Browsable(true)] + [Description("设置文本框的值")] + public string Value + { + get + { + return textBox1.Text; + } + set + { + textBox1.Text = value; + } + } + + [Browsable(true)] + [Description("设置标签的值")] + public string Label + { + get + { + return label1.Text; + } + set + { + label1.Text = value; + } + } + + [Browsable(true)] + [Description("设置是否显示打开按钮")] + public bool DispalyOpenButton + { + get + { + return button1.Visible; + } + set + { + button1.Visible = value; + textBox1.ReadOnly = button1.Visible; + } + } + + [Browsable(true)] + [Description("设置是否允许多行")] + public bool AllowMultiline + { + get + { + return textBox1.Multiline; + } + set + { + textBox1.Multiline = value; + if (textBox1.Multiline) + { + textBox1.ScrollBars = ScrollBars.Vertical; + } + } + } + + [Browsable(true)] + [Description("设置屏蔽密码的字符")] + public char PasswordChar + { + get + { + return textBox1.PasswordChar; + } + set + { + textBox1.PasswordChar=value; + } + } + + public void ValueFor(Expression> selectField, string fieldValue, bool displayBtn = false, bool allowMultiline=false) where TEntity : class + { + var fieldInfo = General.GetPropertyInfo(selectField); + this.Label = General.GetDisplayName(fieldInfo); + this.Value = fieldValue; + this.DispalyOpenButton = displayBtn; + this.AllowMultiline = allowMultiline; + } + + private void button1_Click(object sender, EventArgs e) + { + if (this.OnOpen != null) + { + this.OnOpen(this, null); + } + } + } +} diff --git a/learngit/ChanShuYi.txt b/learngit/ChanShuYi.txt new file mode 100644 index 0000000000..17f5d64f55 --- /dev/null +++ b/learngit/ChanShuYi.txt @@ -0,0 +1,6 @@ +Thanks for your asesome Git Lesson. It help us open the eyes to the open source project world. I use two day's time to learn how to use git through your leasson. I really like your word of your Git Lesson and it's so easy to understand. + +All in all, I hope you have a better life and write more useful and high-qualified lesson. + +Thank you again. +Thank you again. diff --git a/learngit/ChunleiGuo_pull_request.txt b/learngit/ChunleiGuo_pull_request.txt new file mode 100644 index 0000000000..8fc2d66b1f --- /dev/null +++ b/learngit/ChunleiGuo_pull_request.txt @@ -0,0 +1,3 @@ +This is a 'pull_request' test from ChunleiGuo, +and I have learnt a lot about Git from Mr Liao. +Thank you! \ No newline at end of file diff --git a/learngit/ColinPullTest.txt b/learngit/ColinPullTest.txt new file mode 100644 index 0000000000..bc74dab9c8 --- /dev/null +++ b/learngit/ColinPullTest.txt @@ -0,0 +1,2 @@ +This is Colin's Txt +This is my code! diff --git a/learngit/DentistXu.txt b/learngit/DentistXu.txt new file mode 100644 index 0000000000..e366eada6a --- /dev/null +++ b/learngit/DentistXu.txt @@ -0,0 +1,7 @@ +Very Cool tutorials. Easy to read. Leaned a lot. + +Above is added in master branch. + +Bellow is added in a new branch dev, just for a test. + +michaelliao is a nice person and a very good mentor. diff --git a/learngit/Dingshijie.txt b/learngit/Dingshijie.txt new file mode 100644 index 0000000000..01bda02be4 --- /dev/null +++ b/learngit/Dingshijie.txt @@ -0,0 +1,2 @@ +Thank you for sharing. And i will recommend the web site to others. +Best wishes! diff --git a/learngit/Dmicc b/learngit/Dmicc new file mode 100644 index 0000000000..710deb8fa4 --- /dev/null +++ b/learngit/Dmicc @@ -0,0 +1 @@ +Thanks a lot. diff --git a/learngit/DwyaneTalk.txt b/learngit/DwyaneTalk.txt new file mode 100644 index 0000000000..9ab1fc1743 --- /dev/null +++ b/learngit/DwyaneTalk.txt @@ -0,0 +1,2 @@ +非常感谢老师,通过您这份教程,我对Git有了更加全面的认识,相信这份教程一定会帮助很多人的,支持老师 +PS:刚刚陷入文字编码的坑,原来在bash里新建文件之后,使用vi打开编辑,会以ANSI格式编码…… \ No newline at end of file diff --git a/learngit/Engineering-Course.txt b/learngit/Engineering-Course.txt new file mode 100644 index 0000000000..9f9e5a99aa --- /dev/null +++ b/learngit/Engineering-Course.txt @@ -0,0 +1,5 @@ +I'm surprised to find such a good tutorial. +I knew nothing about git before I read it. +But now, I can't wait to work with git. +The turorial is easy to understand. +Thank you very much. \ No newline at end of file diff --git a/learngit/Farb.txt b/learngit/Farb.txt new file mode 100644 index 0000000000..ec3ca3890e --- /dev/null +++ b/learngit/Farb.txt @@ -0,0 +1,12 @@ +***************Git学习心得******************** + 你好,Michael,很高兴认识你这位大牛!我是一名大四学生, +广州读的大学,现在在杭州实习,来到杭州也是为了追求自己心爱的女孩。 +今天是星期日,不算很冷吧,但我依然坐在床上看着你的Git教程。之前对VCS一点都不了解, +只知道只是个版本控制系统的英文单词,具体怎么用真的找不到入门的好资料,几天在coding.net这个 +网站【类似于中国版的GitHub】的帮助说明中看到了他们推荐了你的教程,这才无意认识了你这个教我Git入门的师傅。 +从早上一直看到现在,还没看完,还差一点点了,但是明天还要早起来上班,所以今晚就写完这个心得就洗洗睡了。 +感觉学到了很多,而且不知道是因为动了脑子还是怎地,今晚胃口大开,吃了好多,一碗面加一盘鸡腿套餐,哈哈! +现在在公司,主管让我用的TortoiseSVN,感觉已经上手了,今天再来学习你的Git感觉还不算很难,也可能是你讲的浅显易懂吧! +好吧,听你的忠告,以后就要Git了,明天就劝主管让他改用Git,还能剩下租用阿里云服务器的费用哈哈!晚安!我给你 +发的pullrequest 你一定要接受哦! +***************Git学习心得******************** \ No newline at end of file diff --git a/learngit/GitOfHalu126.txt b/learngit/GitOfHalu126.txt new file mode 100644 index 0000000000..27529c78d7 --- /dev/null +++ b/learngit/GitOfHalu126.txt @@ -0,0 +1,77 @@ +1、git init:初始化一个Git仓库。 +2、添加文件到Git仓库,分两步: + 第一步,使用命令git add ,注意,可反复多次使用,添加多个文件; + 第二部,使用命令git commit -m "提交说明",完成。 +3、git status:打印整个工作区的状态。 +4、git diff :查看修改内容。 +5、git log:查看系统中的历史commit提交记录 + 如:git log 或git log --pretty=oneline + 其中pretty指定打印提交记录内容的格式,可选的值有:oneline,short,medium,full,fuller,email,raw和一些自定义的字符格式。 + 补充: + --graph可以看到分支合并图。 + --abbrev-commit打印简短commit-id。 +6、git reset --hard :将head的值设定为指定的commit_id, + HEAD表示当前版本id, + HEAD^表示上一个版本id, + HEAD^^表示上上一个版本id, + HEAD~100表示上上100个版本id, + 版本id也可以在git log命令中查看,commit就是。 +7、git reflog:记录你的每一次有关head的历史命令记录 +8、工作区(Working Directory):就是当前的工作目录。 + 版本库(Repository):工作区下的隐藏目录.git。 + 暂存区(stage):版本库中的index(或者是stage)文件。 + git add命令就是把文件修改添加到暂存区(stage)中; + git commit命令就是把暂存区的所有内容提交到当前分支中。(如下图) + +9、git checkout -- :把工作区中对filename文件的修改撤销掉 + 这里有两种情况: + 一种是修改后还没放到暂存区(即:还没有使用git add命令),现在撤销修改就是回到和版本库一模一样的状态; + 一种是已经添加到暂存区后,又作了修改,现在撤销修改就是回到添加到暂存区后的状态。 + 总之,就是让这个文件回到最近一次git commit或git add时的状态 + 补充: + git checkout :切换到相应的分支上。 +10、git reset HEAD :把暂存区中对filename的修改撤销掉(此步是把修改从暂存区撤销到工作区,要想撤销工作区的修改,要进一步的使用git checkout -- 命令) + 如果修改已经提交到版本库中了,在没有把本地版本推送到远程的情况下可以使用git reset --hard 命令进行版本回退了。 +11、git rm :在暂存区记录下要删除文件filename,使用git commit命令提交删除申请,从版本库中删除文件。 +12、ssh-keygen -t rsa -C "youremail@example.com":使用自己的邮件在用户主目录下生成SSH key。(要在主目录下运行此命令) + -t 指定加密方式,可以值有:rsa、dsa,默认为:dsa + -C是添加注解comment,可以不是自己的邮件,也可以不要此项。 +13、git remote add origin git@github.com:/<仓库名>.git 将本地仓库与github上的仓库关联起来。 + origin为远程库的名字。 +14、git push -u origin master:将本地库的所有内容推送到远程库上。(只有第一次推送的时候才加上-u) +15、git config --global user.name "用户名":配置缺省的用户名。 +16、git config --global user.email "":配置缺省的email,最好和注册时使用一样的email。 +17、git clone git@github.com:<用户名>/<仓库名>.git:从远程库中克隆版本库到本地。 +18、git branch:查看分支。 + 补充: + git branch --set-upstream branch-name origin/branch-name:创建本机分支与远程分支的链接关系。 +19、git branch :创建分支name。 +20、git checkout :切换到分支name。 +21、git checkout -b :创建并切换到分支name。 +22、git merge :合并name分支到当前分支中。 + 如果合并的时候产生了冲突,git会告诉我们在哪个文件上产生了冲突(git status也会告诉我们冲突的文件),必须手动解决冲突后在提交。 + 补充: + --no-ff参数表示禁止使用Fast forward模式合并,应为本次合并要创建一个新的commit,所以要加入-m,将commit描写写进去。 +23、git branch -d :删除分支name。 + 补充: + git branch -D :强行删除那么分支。 +24、git stash:把当前工作现场储藏到工作栈中(入栈操作)。 +25、git stash list:查看储藏工作现场的栈里的内容。 +26、git stash apply stash@{n}:将工作栈中的第n个工作现场回复出来。 +27、git stash drop:删除工作栈中第一个工作现场。 +28、git stash pop:回复工作现场的同时把相应的内容从工作栈中删除。(出栈操作)。 +29、git remote:查看远程库信息。 + -v:查看远程库详细信息,其中fetch是抓取地址;push是推送地址。 +30、git pull:把别人最新的提交从远程上抓取下来。 +31、git tag [commit-id]:在commit-id处创建一个标签,commit-id默认为HEAD。 + -a tagname -m "blablabla...":指定标签信息。 + -s tagname -m "blablabla..." :可以使用PGP签名标签。 +32、git tag:查看所有标签。 +33、git show :查看标签详细信息。 +34、git tag -d :删除本地标签。 +35、git push origin :refs/tags/tagname:删除一个远程标签。 +36、git push origin origin tagname:推送标签到远程。 +37、git push origin --tags:推送全部标签到远程。 +38、.gitignore文件:忽略特殊文件,https://github.com/github/gitignore。 + +大家辛苦了,comment里面欣赏下美女吧! diff --git a/learngit/Git_Commands@pengloo53.md b/learngit/Git_Commands@pengloo53.md new file mode 100644 index 0000000000..847adcb3ee --- /dev/null +++ b/learngit/Git_Commands@pengloo53.md @@ -0,0 +1,98 @@ +--- + +layout: post +title: "Git 常用命令" + +--- +###学会这些命令,你就可以熟练的使用Git工具了,什么?想精通,那是不可能的。 +####基本上,Git就是以下面的命令顺序学习的。文中笔记是从廖雪峰老师的[Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000)中总结出来的,方面查阅命令。详细原理请看[Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000) +####1、基础 +- `git config --global user.name "Your Name"`设置你的仓库用户名(用于标识提交者) +- `git config --global user.email "email@example.com"`设置你的仓库邮箱(用于标识提交者) +- `git init` 初始化一个git仓库 +- `git add --all` 添加所有更改的文件 +- `git add filename1` 当然可以指定添加filename1 +- `git commit -m "commit message"` 添加更改的信息,必须要有,不然报错,不建议不加。 +- `git status` 查看git当前状态 +- `git diff filename1` 查看filename1到底修改了哪些内容 +- `git log` 查看最近的提交日志 +- `git log --pretty=oneline` 单行显示提交日志 +- `git reset --hard commitID` 利用`git log`得到的commitID返回版本 +- `git reset --hard HEAD^`回到上一个版本 +- `git reflog` 查看命令的历史,可以找到`git log`看不到的commitID,因为`git log`只显示当前的提交日志,如果你提交了一次,退回版本后又后悔了,就能查看上次提交的commitID +- `git checkout -- filename1` 利用版本库中的版本替换工作区中的文件。功能有2: + - 撤销文件修改,分两种情况: + - 撤销工作区中的修改(没有使用`git add`命令添加到暂存区) + - 撤销暂存区中的修改(添加到了暂存区又做了修改) + - 找回删除的文件 + - 工作区中文件误删了,可以通过此命令从版本库中找回 +- `git reset HEAD filename1` 撤销add,回到工作区 +- `git rm filename1` 删除文件 +- `git remote add origin https://github.com/pengloo53/learngit.git` 将本地库关联到github远程库上 +- `git push -u origin master` 第一次推送的时候要加上`-u`参数,可以将本地库的master分支与远程库的master分支关联起来;下次提交就不需要加`-u`了。 +- `git clone https://github.com/pengloo53/learngit.git` 克隆远程库到本地 + +####2、分支管理 +- `git checkout -b dev`创建dev分支并切换到dev。相当于`git branch dev`、`git checkout dev`两条命令。 +- `git branch`查看当前分支 +- `git merge dev`合并指定分支到当前分支,如,你现在master分支,那么执行命令就将dev分支合并到了master分支上。 +- `git branch -d dev`删除dev分支 +- `git log --graph --pretty=oneline --abbrev-commit`查看分支合并图 +- `git merge --no-ff -m "merge with no-ff" dev`禁用「Fast forward」,也就是保留分支的相关信息。 +- `git stash` 将工作区现场储藏起来,等以后恢复后继续工作。通常用于处理更为着急的任务时,例如:bug。 +- `git stash list` 查看保存的工作现场 +- `git stash apply`恢复工作现场 +- `git stash drop` 删除stash内容 +- `git stash pop` 恢复的同时直接删除stash内容 +- `git stash apply stash@{0}` 恢复指定的工作现场,当你保存了不只一份工作现场时。 +- `git branch -D feature-vulcan` 强行删除分支。用于不需要合并,就地删除的情况。 +- `git remote` 查看远程库的信息,一般返回origin。 +- `git remote -v` 查看远程库的详细信息。 +- `git push origin master` 将本地master分支推送到远程master分支。 + - master分支为主分支,因此要时刻与远程同步; + - dev分支为开发分支,团队成员都需要在上面工作,所以也需要与远程同步; + - bug分支只用于在本地修复bug,没有必要推送到远程; + - feature新功能分支是否推送到远程,取决于你是否和其他人合作在上面开发。 +- `git clone https://github.com/pengloo53/learngit.git` 将远程库克隆到本地,默认只能看到master分支。 +- `git checkout -b dev origin/dev` 创建远程dev分支到本地 +- `git pull` 将远程分支的最新内容抓取下来。 +- `git branch --set-upstream dev origin/dev`将本地dev分支与远程dev分支之间建立链接。 + +#####_多人协作工作模式_ +1. 首先,可以试图用`git push origin branch-name`推送自己的修改; +2. 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并(如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令`git branch --set-upstream branch-name origin/branch-name`); +3. 如果合并有冲突,则解决冲突,并在本地提交; +4. 没有冲突或者解决掉冲突后,再用`git push origin branch-name`推送就能成功! + +####3、标签管理 +- `git tag v1.0` 给当前分支打上标签 +- `git tag` 查看所有的标签,按时间顺序列出。 +- `git log --pretty=oneline --abbrev-commit`缩略commitID并单行显示提交信息 +- `git tag v0.9 commitID`通过上一条命令查看commitID,然后打上标签。用于忘记打标签的情况,因为标签其实就是只想某个commitID的指针,默认情况下,标签打在最新的提交上。 +- `git show v0.9` 查看标签信息。 +- `git tag -a v0.1 -m "version 0.1 released" commitID`创建带有说明的标签,`-a`指定标签名,`-m`指定说明文字。 +- `git tag -d v0.1` 删除标签v0.1 +- `git push origin v1.0` 推送标签1.0到远程 +- `git push origin --tags` 推送所有的标签到远程 +- `git push origin :refs/tags/v0.9` 删除远程标签,但是前提是要先在本地删除对应标签。 + +####4、自定义GitHub +- `git config --global color.ui true` 让Git显示颜色 +- `.gitignore`在这个文件里编辑你要忽略的文件,并提交到Git中,就可以忽略特殊文件的检查。如将`*.db`写入`.gitignore`文件中,将忽略所有db文件。可以参考[github收集的所有.gitignore](https://github.com/github/gitignore) +- `git config --global alias.st status`将status的别名设置成st,那么`git st`=`git status`。 +- `git config --global alias.unstage 'reset HEAD'` 那么`git reset HEAD filename`=`git unstage filename` +- `git config --global alias.last 'log -1'` 敲`git last`就显示最后一次提交了。 + +####5、搭建Git服务器 +1. `sudo apt-get install git` 安装Git; +2. `sudo adduser git` 添加Git用户; +3. `sudo git init --bare sample.git` 初始化git仓库; +4. `sudo chown -R git:git sample.git`修改仓库的所属用户为git; +5. 将git用户的信息`git:x:1001:1001:,,,:/home/git:/bin/bash`改成`git:x:1001:1001:,,,:/home/git:/bin/git-shell`,为了禁用shell登录。 +6. `git clone git@server:/director/sample.git` 克隆Git服务器上的仓库 + +_PS. 想方便管理公钥,用[Gitosis](https://github.com/res0nat0r/gitosis);想控制权限,用[Gitolite](https://github.com/sitaramc/gitolite)。_ + + + + diff --git a/learngit/GreenLim.txt b/learngit/GreenLim.txt new file mode 100644 index 0000000000..904ff23594 --- /dev/null +++ b/learngit/GreenLim.txt @@ -0,0 +1 @@ +thanks a lot for these wonderful feeds! \ No newline at end of file diff --git a/learngit/Horve.txt b/learngit/Horve.txt new file mode 100644 index 0000000000..a7006d4ca6 --- /dev/null +++ b/learngit/Horve.txt @@ -0,0 +1,198 @@ +创建版本库 + +$ git init +把目录变成Git可以管理的仓库(Git仓库) + +$ git add file +把file文件添加到仓库 + +$ git commit -m ‘commit logic’ +将暂存区内的改动提交到仓库,并加上’commit logic’的提交日志 + +$ git status +仓库的状态,包括有无修改,是否已经完全提交到仓库 + +$ git diff file +暂存区和版本库中file文件的区别 + + +版本回退 + +$ git log +仓库内文件的修改日志 + +$ git reset --hard HEAD^ +回退到上一个版本 + +$ git reset --hard HEAD^^ +回退到倒数第二个版本 + +$ git reset --hard HEAD~100 +回退到倒数第100个版本 + +$ git reset --hard ‘commit_id’ +根据git log命令得到的结果中的commit_id,回退到对应版本(commit_id只写前几位就行) + +$ git reflog +记录每一次命令 + +注:Gti的版本回退速度非常快,因为Git在内部有个指向当前版本的HEAD指针,当你回退版本的时候,Git仅仅是把HEAD指针从原始版本指向当前版本。HEAD指向的版本始终是当前版本。 + +管理修改 + +$ git diff HEAD -- file +工作区和版本库里file文件最新版的区别 + +$ git checkout -- file +把file在工作区中的更改全部撤销。PS: “--”很重要,没有“—”就变成了一个创建新分支的命令。 + +$ git reset HEAD file +把file在暂存区中的修改全部撤销(unstage),重新放回工作区(就是回到git add命令之前)。 + +$ rm file +从工作区中删除文件,不能影响版本库 + +$ git rm file +从版本库中删除文件,并且要git commit提交改动 + +github + +$ git remote add origin ‘git-ssh-url’ +把一个本地仓库与GitHub仓库关联 + +$ git push -u origin master +第一次推送master分支的所有内容【把本地库的内容推送到远程库上】 + +$ git push origin master  +每次本地提交后,都能使用改名了推送到远程库 + +$ git clone ‘git-ssh-url’ +从远程库克隆一个本地库 + +PS:GitHub给出的地址不止一个,还可以用https://github.com/xxxxx/xxxx.git这样的地址。实际上,Git支持多种协议,默认的git://使用ssh,但也可以使用https等其他协议。 + +使用https除了速度慢以外,还有个最大的麻烦是每次推送都必须输入口令,但是在某些只开放http端口的公司内部就无法使用ssh协议而只能用https。 + +与远程版本库关联并同步文件的流程: +1,创建SSH Key并对GitHub进行配置; +2,在GitHub上创建远程库; +3,本地目录通过git init,git add, git commit等命令将本地目录配置成Git仓库,并提交更新; +4,git remote add origin ‘git-ssh-url’命令将本地库与远程库关联; +5,git push -u origin master命令将本地库所有的内容推送到远程库,第一次带-u,以后不用带。 + +创建与合并分支 + +$ git branch -b dev +创建并切换到分支dev + +$ git branch dev +创建分支dev + +$ git checkout dev +切换到分支dev + +$ git branch  +列出所有分支,并标示出当前分支 + +$ git merge dev +把dev分支的结果合并到当前分支 + +$ git branch -d dev +删除dev分支 + +$ git log --graph +查看分支合并图 + +$ git merge --no-ff -m “no-ff merge” dev +通过no-ff模式(非Fast forward模式)合并dev分支到当前分支 + +PS:通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息 +如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息,也就是合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + +Bug分支 + +$ git stash  +存储当前工作现场,修复bug后恢复工作现场 + +$ git stash list +查看所有存储的工作现场 + +$ git stash apply +恢复所有的工作现场 + +$ git stash pop +删除所有的工作现场 + +$ git stash apply stash@{N}  +恢复指定的工作现场 + +$ git branch -D dev +强行删除没有被合并的分支dev + +多人协作 + +$ git remote +查看远程库信息 + +$ git remote -v +查看远程库更多信息,如: +origin git@github.com:Horve/ws-exam.git (fetch) +origin git@github.com:Horve/ws-exam.git (push) +PS:上面显示了可以抓取和推送的origin的地址。如果没有推送权限,就看不到push的地址。 + +$ git push origin master +将master分支上所有的本地提交推送到远程库 + +抓取分支 + +团队成员从远程库clone时,默认情况下,他将只能看到本地的master分支。如果需要在其他的分支上进行开发,就需要创建远程origin的其他分支到本地。 + +$ git checkout -b dev origin/dev +创建远程的dev分支到本地 + +$ git branch --set-upstream dev origin/dev +建立本地分支与远程分支之间的链接/关联 + +多人协作的工作模式 + +1,首先,可以试图用git push origin branch-name推送自己的修改; +2,如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; +3,如果合并有冲突,则解决冲突,并在本地提交; +4,没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! +5,如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +创建标签 + +$ git tag v1.0 +为当前分支创建标签v1.0,默认为HEAD创建 + +$ git tag +查看分支所有标签(标签不是按时间顺序列出,而是按字母排序的) + +$ git tag v0.9 commit_id +为对应的commit版本创建标签(可通过git log查看commit日志获取对应版本的commit_id) + +$ git show v0.9 +根据标签查找对应的版本 + +$ git tag -a v1.0 -m “version 1.0 released” commit_id +创建带有说明的标签,-a指定标签名,-m指定说明文字 + +操作标签 + +$ git tag -d v1.0 +删除标签。创建的标签都只存储在本地,不会自动推送到远程。所以打错的标签可以在本地安全删除。 + +$ git push origin v1.0 +推送v1.0标签到远程版本库 + +$ git push origin --tags +一次性推送全部尚未推送到远程的本地标签 + +删除远程标签 + +$ git tag -d v0.9 +首先删除本地标签 + +$ git push origin :refs/tags/v0.9 +然后用这条命令删除远程标签 \ No newline at end of file diff --git a/learngit/HsingChin.txt b/learngit/HsingChin.txt new file mode 100644 index 0000000000..4d5b341482 --- /dev/null +++ b/learngit/HsingChin.txt @@ -0,0 +1,2 @@ +Dear Michael: + This Git lesson is very helpful, thanks a lot, it was you who show me the door to the amazing world of git. diff --git a/learngit/HuChengzhen.txt b/learngit/HuChengzhen.txt new file mode 100644 index 0000000000..8307abdc6f --- /dev/null +++ b/learngit/HuChengzhen.txt @@ -0,0 +1 @@ +跟着这个教程学习,感觉很棒 \ No newline at end of file diff --git a/learngit/Java.gitignore b/learngit/Java.gitignore new file mode 100644 index 0000000000..46775e45bc --- /dev/null +++ b/learngit/Java.gitignore @@ -0,0 +1,3 @@ +*.class + + \ No newline at end of file diff --git a/learngit/JiangbinWu.md b/learngit/JiangbinWu.md new file mode 100644 index 0000000000..e1a905bf2d --- /dev/null +++ b/learngit/JiangbinWu.md @@ -0,0 +1,4 @@ +Thanks! +========= + +Thanks for your Git lessons. diff --git a/learngit/JoeZhouWenxuan.md b/learngit/JoeZhouWenxuan.md new file mode 100644 index 0000000000..58e2592d61 --- /dev/null +++ b/learngit/JoeZhouWenxuan.md @@ -0,0 +1,2 @@ +this is a test + diff --git a/learngit/JohnTsaiAndroid.txt b/learngit/JohnTsaiAndroid.txt new file mode 100644 index 0000000000..14ae176bd9 --- /dev/null +++ b/learngit/JohnTsaiAndroid.txt @@ -0,0 +1 @@ +Thank you,Mr Liao. diff --git a/learngit/KID-G-two.txt b/learngit/KID-G-two.txt new file mode 100644 index 0000000000..46c6009c81 --- /dev/null +++ b/learngit/KID-G-two.txt @@ -0,0 +1 @@ +hello michaelliao,I am a teacher for PHP,thank you for your help on git! diff --git a/learngit/KID-G.txt b/learngit/KID-G.txt new file mode 100644 index 0000000000..a042389697 --- /dev/null +++ b/learngit/KID-G.txt @@ -0,0 +1 @@ +hello world! diff --git a/learngit/Kandane.txt b/learngit/Kandane.txt new file mode 100644 index 0000000000..afb0a8fd80 --- /dev/null +++ b/learngit/Kandane.txt @@ -0,0 +1,9 @@ +快毕业找工作了,在复习的时候才知道有版本管理器,自己对着很古老的一本书 +从RCS开始看起的,看过CVS 和 SVN ,最后看的GIT。从网上搜到你的教程,之前 +有人说中文的GIT的教程不多,学起来不容易。我对着你的教程学到现在,感觉其 +实也不是很难,当然这也是你的教程写的水平比较高,比较生动的原因。在这里 +十分的感谢你,能够花费这么多的精力来写下这份教程。 +感觉GIT比较适合现在的我使用。当然我也没有发现大家说的CVS的问题。还是使 +用的深度不够。把这个体验完打算去试试开源中国假设的GIT托管网站,看看有什 +么不同。 +最后再次感谢你。 diff --git a/learngit/Kean.txt b/learngit/Kean.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/learngit/Kevin--Wu.txt b/learngit/Kevin--Wu.txt new file mode 100644 index 0000000000..a0e9a7f568 --- /dev/null +++ b/learngit/Kevin--Wu.txt @@ -0,0 +1,4 @@ +Mr.liao: + Thank you for your awesome Git lessons.It helps me a lot in exploring this new world. + Kevin--Wu + 2015/2/10 diff --git a/learngit/Kevin.txt b/learngit/Kevin.txt new file mode 100644 index 0000000000..87f5edcdad --- /dev/null +++ b/learngit/Kevin.txt @@ -0,0 +1 @@ +Love you! teacher! \ No newline at end of file diff --git a/learngit/KiritoSai.md b/learngit/KiritoSai.md new file mode 100644 index 0000000000..25ba103099 --- /dev/null +++ b/learngit/KiritoSai.md @@ -0,0 +1,3 @@ +#the first pull request of KiritoSai +1. Thank you for the best git lesson i have ever seen. +2. This is my first pull request. \ No newline at end of file diff --git a/learngit/LICENSE b/learngit/LICENSE new file mode 100644 index 0000000000..94a9ed024d --- /dev/null +++ b/learngit/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/learngit/LYJ_LYJ@126.com b/learngit/LYJ_LYJ@126.com new file mode 100644 index 0000000000..dc36b02476 --- /dev/null +++ b/learngit/LYJ_LYJ@126.com @@ -0,0 +1 @@ +看了作者的博客,终于感觉对git有了一些基础理解了,作者提供了这么详细易懂的基础教程,小白再次表示深深的谢意。 diff --git a/learngit/Linyanyu.txt b/learngit/Linyanyu.txt new file mode 100644 index 0000000000..f2eb78997c --- /dev/null +++ b/learngit/Linyanyu.txt @@ -0,0 +1 @@ +thank you mr liao diff --git a/learngit/Luodinonesheng@gmail.com b/learngit/Luodinonesheng@gmail.com new file mode 100644 index 0000000000..8690d39f8d --- /dev/null +++ b/learngit/Luodinonesheng@gmail.com @@ -0,0 +1 @@ +i'm learning the git! git is very cool and strong!i like it!and i really want test how to pull request,so ,i hope teacher liao that you can take this file!thank you ! diff --git a/learngit/MyCourseOfGIt.txt b/learngit/MyCourseOfGIt.txt new file mode 100644 index 0000000000..2959c4d203 --- /dev/null +++ b/learngit/MyCourseOfGIt.txt @@ -0,0 +1 @@ +花了一周时间学习了git的使用,感谢博主的博文,给了我非常大的帮助 \ No newline at end of file diff --git a/learngit/MyUbuntuGitHub.txt b/learngit/MyUbuntuGitHub.txt new file mode 100644 index 0000000000..9b9825769a --- /dev/null +++ b/learngit/MyUbuntuGitHub.txt @@ -0,0 +1,7 @@ +-*- coding: utf-8 -*- + +Without doubt, this is the best articles I have ever read about GitHub. + +Thanks a lot, best wish. + +Kaka **_** diff --git a/learngit/NCRD.txt b/learngit/NCRD.txt new file mode 100644 index 0000000000..70513614ff --- /dev/null +++ b/learngit/NCRD.txt @@ -0,0 +1 @@ +This is from NCRD lab of Nanjing university in China. diff --git a/learngit/Nice-PLQ.txt b/learngit/Nice-PLQ.txt new file mode 100644 index 0000000000..8f91114b87 --- /dev/null +++ b/learngit/Nice-PLQ.txt @@ -0,0 +1 @@ +This is the first time that I have learn Git. \ No newline at end of file diff --git a/learngit/Notes_LearningGit.md b/learngit/Notes_LearningGit.md new file mode 100644 index 0000000000..eec28a2215 --- /dev/null +++ b/learngit/Notes_LearningGit.md @@ -0,0 +1,148 @@ +##Git 初步 +初始化一个Git仓库,使用`git init`命令。 + +添加文件到Git仓库,分两步: + +1. 使用命令`git add `,注意,可反复多次使用,添加多个文件; +2. 使用命令`git commit`,完成。 +通常使用 `git commit -m "something to comment"` +3. 注意,每次commit前都先要`add commit`,如果在commit前没有add,那么只会commit到之前add时候的内容 + +##Git查看 +* 要随时掌握工作区的状态,使用`git status`命令。 +* 如果`git status`告诉你有文件被修改过,用`git diff`可以查看修改内容。 +* 使用`git log`来查看git commit记录 +* 也可以使用`git log --pretty=oneline` 一行显示 + +##版本回退 +HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令: + +* `git reset --hard commit_id` 回退到id的版本 +* `git reset --hard HEAD^` 回退一个版本 +* `git reset --hard HEAD^^` 回退两个版本 +* `git reset --hard HEAD~100` 回退一百个版本 + +穿梭前,用`git log`可以查看提交历史,以便确定要回退到哪个版本。 +要重返未来,用`git reflog`查看命令历史,以便确定要回到未来的哪个版本。 + +##工作区与暂存区 +`git add`命令实际上就是把要提交的所有修改放到暂存区(Stage) + +![git add](/Users/Des/Documents/Coding/notes/image/git add.jpeg) +`git commit`就可以一次性把暂存区的所有修改提交到分支。 + +![git commit](/Users/Des/Documents/Coding/notes/image/git commit.jpeg) + +##撤销修改 撤销删除 +删除文件 使用 rm file,但是如果想要版本库也删除的话 需要使用 `git rm file` + +1. 当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令`git checkout -- file`。 git checkout其实是用版本库里的版本替换工作区的版本,如果在无论工作区是修改还是删除,比如不小心删掉文件了,使用`git checkout --file`都可以“一键还原”,将这个工作区的文件用版本库里边的恢复。 + +2. 当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,即已经进行了`add`操作,想丢弃修改,分两步,第一步用命令`git reset HEAD file`,就回到了场景1,第二步按场景1操作。 + +3. 已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + +##远程连接 +####从本地拷贝到远程库 +cd到要拷贝的git的文件夹 + +1. 要关联一个远程库,使用命令 `git remote add origin git@server-name:path/repo-name.git`; +2. 比如 `git remote add origin git@github.com:rwang23/xx.git` + +2. 关联后,使用命令`git push -u origin master`第一次推送master分支的所有内容,如果不是master分支,换名字就可以; + +3. 此后,每次本地提交后,只要有必要,就可以使用命令`git push origin master`推送最新修改; + +分布式版本系统的最大好处之一是在本地工作完全不需要考虑远程库的存在,也就是有没有联网都可以正常工作,而SVN在没有联网的时候是拒绝干活的!当有网络的时候,再把本地提交推送一下就完成了同步,真是太方便了! + +####从远程库克隆到本地 +进入要克隆到的文件夹, +`git clone git@github.com:michaelliao/gitskills.git` +Git支持多种协议,包括https,但通过ssh支持的原生git协议速度最快。 + +##分支管理 +Git鼓励大量使用分支: + +* 查看分支:`git branch` +* 创建分支:`git branch ` +* 切换分支:`git checkout ` +* 创建+切换分支:`git checkout -b ` +* 合并某分支到当前分支:`git merge ` +* 删除分支:`git branch -d ` +* 开发一个新feature,最好新建一个分支;如果要丢弃一个没有被合并过的分支,可以通过`git branch -D `强行删除。 + +合并分支的时候如果出现冲突,那么将会出现冲突提醒 +并在当前分支上出现: + + <<<<<<< HEAD + Creating a new branch is quick & simple. + ======= + Creating a new branch is quick AND simple. + >>>>>>> feature1 +修改好后再次提交就可以了 +同时 可以使用 git log 或者git log --graph指令来查看分支与分支合并情况 + +通常情况下使用合并分支Git会自动使用`Fast forward`模式,但是这种情况下删除分支后,会丢失分支信息, +这个时候我们可以使用--no-ff方式下的`git merge`,它会提交一个新的commit +`git merge --no-ff -m "merge with no-ff" dev` + + +###分支策略 + +* master分支应该是非常稳定的,也就是仅用来发布新版本的 +* 一般干活都在dev分支上的,一般来说dev分支是不稳定的,比如到了某个时候才合并到master上边,在master上边发布新版本 +![git branch merge](/Users/Des/Documents/Coding/notes/image/git branch&merge.png + +####Bug出现的修复 + +* 当正在新的branch进行工作时,想要修复原来的branch比如master的bug,这个时候就想切换到master。 + +* 但是此时由于branch还没完成不能提交,所以我们可以使用`git stash`来储存当前工作现场 + +* 然后就可以切换到要修改Bug的branch然后创建bug新分支再用原分支合并,再切换到刚才的新brach工作 + +如何储存工作现场? + +1. 使用`git stash`来储存当前工作现场 + +2. 可以使用`git stash list`来查看当前工作现场 + +3. 工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: + +* 一是用`git stash apply`恢复,但是恢复后,stash内容并不删除,你需要用`git stash drop`来删除; + +* 另一种方式是用`git stash pop`,恢复的同时把stash内容也删了: + +##多人协作 +查看远程库信息,使用git remote -v; + +多人协作的工作模式通常是这样: + +1. 首先,可以试图用git push origin branch-name推送自己的修改; + +2. 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +3. 如果合并有冲突,则解决冲突,并在本地提交; + +4. 没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +5. 如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单。 + +##标签管理 + +###创建标签 +* 命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; +* git tag commit_id 在该commit_id上打上标签 +* git tag -a -m "blablabla..." commit_id可以指定标签信息; +* git tag -s -m "blablabla..."可以用PGP签名标签; +* 命令git tag可以查看所有标签。 + +###修改标签 +因为创建的标签都只存储在本地,不会自动推送到远程。所以,打错的标签可以在本地安全删除。 + +* 命令`git push origin tagname`可以推送一个本地标签; +* 命令`git push origin --tags`可以推送全部未推送过的本地标签; +* 命令`git tag -d tagname`可以删除一个本地标签; +* 命令`git push origin :refs/tags/`可以删除一个远程标签。 \ No newline at end of file diff --git a/learngit/PanYutong.txt b/learngit/PanYutong.txt new file mode 100644 index 0000000000..50d45631f4 --- /dev/null +++ b/learngit/PanYutong.txt @@ -0,0 +1,2 @@ +非常感谢廖雪峰写的这个github教程,帮助我从0开始迅速上手使用github +P.S.作者太可爱了。。。 diff --git a/learngit/PeterAnderson.txt b/learngit/PeterAnderson.txt new file mode 100644 index 0000000000..0a3c481c2e --- /dev/null +++ b/learngit/PeterAnderson.txt @@ -0,0 +1 @@ +Thanks a lot, Xuefeng Liao, your tutorial is very good for the little birds! \ No newline at end of file diff --git a/learngit/PretendDemo.txt b/learngit/PretendDemo.txt new file mode 100644 index 0000000000..655284924b --- /dev/null +++ b/learngit/PretendDemo.txt @@ -0,0 +1 @@ +thanks your guide! diff --git a/learngit/README.md b/learngit/README.md new file mode 100644 index 0000000000..32486a95a6 --- /dev/null +++ b/learngit/README.md @@ -0,0 +1,2 @@ +gitskills +========= diff --git a/learngit/Rockyzsu_Git_Study b/learngit/Rockyzsu_Git_Study new file mode 100644 index 0000000000..bf1d388af2 --- /dev/null +++ b/learngit/Rockyzsu_Git_Study @@ -0,0 +1,6 @@ +Hi I am Rocky, now working at NVIDIA, as SWQA. +This blog is very useful for me to learn git one step by step and build up my git repository in github. I need to send my great appriciation to YOU ! +Now i am going to forward this blog to my friends , big alias to learn this course. + +Best regards, +Rocky Chen diff --git a/learngit/RoseWsp.txt b/learngit/RoseWsp.txt new file mode 100644 index 0000000000..eb5a18ce57 --- /dev/null +++ b/learngit/RoseWsp.txt @@ -0,0 +1,211 @@ + +//Sorry i copy from others , for Test + +Skip to content +This repository +Explore +Gist +Blog +Help +@RoseWsp RoseWsp + + Unwatch 1 + Star 0 + Fork 840 +RoseWsp/learngit +forked from michaelliao/learngit + branch: master learngit/your-github-whatswhat.txt +@whatswhatwhatswhat on 8 Nov 2014 try fork and pull request +1 contributor +RawBlameHistory 190 lines (126 sloc) 8.403 kB + + + + + +$ git init 初始化一个Git仓库 + +添加文件到Git仓库,分两步: +$ git add +$ git commit -m "....." + +$ git status + +$ git diff #比较工作区和暂存区文件差异 (Working Directory工作区(add操作前) 和 stage暂存区(add操作后) 的区别) +$ git diff HEAD -- 查看工作区和版本库里面最新版本的区别(Working Directory工作区(add操作前) 和 Repository版本库(commit操作后) 的区别) + + +版本回退: +$ git reset --hard +$ git reset --hard HEAD^ +首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交3628164...882e1e0(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。 + + +$ git log 查看提交历史 +$ git log --pretty=oneline + +$ git reflog 查看命令历史 + + + * +HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 + * +穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 + * +要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本 + + + +撤销修改: +$ git checkout -- readme.txt 把readme.txt文件在工作区的修改全部撤销 丢弃工作区的修改 +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +总之,就是让这个文件回到最近一次git commit或git add时的状态。 + +$ git reset HEAD file 把暂存区的修改撤销掉(unstage),重新放回工作区 + + +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + +远程仓库 +$ git push -u origin master +$ git push origin master + + +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +从远程库克隆: +$ git clone git@github.com:whatswhat/gitskills.git 后面是仓库的地址 ssh(速度快) +$ git clone https://github.com/whatswhat/gitskills.git 后面是仓库的地址 http + +分支管理 +创建与合并分支 + + +查看分支:git branch +创建分支:git branch +切换分支:git checkout +创建+切换分支:git checkout -b +合并某分支到当前分支:git merge +删除分支:git branch -d +解决冲突、分支管理策略 +用git log --graph命令可以看到分支合并图 +$ git log --graph --pretty=oneline --abbrev-commit + + + +通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。--no-ff方式的git merge: 准备合并dev分支,请注意--no-ff参数,表示禁用Fast forward: +$ git merge --no-ff -m "merge with no-ff" dev + + +Bug分支 +Git还提供了一个stash功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作: +$ git stash +$ git stash list + + +工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +$ git stash apply + +$ git stash pop + + + +你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,用命令: + +$ git stash apply stash@{0} + + + +小结 +修复bug时,我们会通过创建新的bug分支进行修复,然后合并,最后删除; +当手头工作没有完成时,先把工作现场git stash一下,然后去修复bug,修复后,再git stash pop,回到工作现场。 + +Feature分支 + +开发一个新feature,最好新建一个分支; +如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 + +多人协作 + + +当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应起来了,并且,远程仓库的默认名称是origin。 +$ git remote 查看远程库的信息 +$ git remote -v 显示更详细的信息(显示可以抓取fetch和推送push的origin的地址) + +推送分支 +推送分支,就是把该分支上的所有本地提交推送到远程库。推送时,要指定本地分支,这样,Git就会把该分支推送到远程库对应的远程分支上: +$ git push origin master +如果要推送其他分支,比如dev,就改成: +$ git push origin dev + +并不是一定要把本地分支往远程推送,那么,哪些分支需要推送,哪些不需要呢? + + * +master分支是主分支,因此要时刻与远程同步; + * +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + * +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + * +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + +总之,就是在Git中,分支完全可以在本地自己藏着玩,是否推送,视你的心情而定! + +抓取分支 +$ git checkout -b dev origin/dev 创建远程origin的dev分支到本地 +$ git branch --set-upstream dev origin/dev 设置本地dev分支与远程origin/dev分支的链接 +$ git pull 把最新的提交从远程origin/dev抓下来 + + +多人协作的工作模式通常是这样: + + 1. +首先,可以试图用git push origin branch-name推送自己的修改; + 2. +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + 3. +如果合并有冲突,则解决冲突,并在本地提交; + 4. +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + + +小结 + + * +查看远程库信息,使用git remote -v; + * +本地新建的分支如果不推送到远程,对其他人就是不可见的; + * +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + * +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + * +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + * +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + +标签管理 +创建标签 +$ git tag 新建一个标签(需先切换到要打标签的分支上)(默认为HEAD,也可以指定一个commit id) +$ git tag -a -m "…" 指定标签信息 +$ git tag -s -m “…" 用PGP签名标签(如果报错,请参考GnuPG帮助文档配置Key。) +$ git tag 查看所有标签 +$ git show 查看标签信息 + +操作标签 +$ git tag -d 删除一个本地标签 +$ git push origin 推送一个本地标签 +$ git push origin --tags 一次性推送全部未推送到远程的本地标签 +$ git push origin :refs/tags/ (从远程删除)删除一个远程标签(需先从本地删除即先执行git tag -d 命令) +Status API Training Shop Blog About +© 2015 GitHub, Inc. Terms Privacy Security Contact diff --git a/learngit/Rowandjj.txt b/learngit/Rowandjj.txt new file mode 100644 index 0000000000..434c723ef2 --- /dev/null +++ b/learngit/Rowandjj.txt @@ -0,0 +1,3 @@ +我觉得这是我看到过的最好的Git教程,没有之一!!! +感谢廖老师! +希望能够推出越来越多的精品教程! \ No newline at end of file diff --git a/learngit/SimbaQ.txt b/learngit/SimbaQ.txt new file mode 100644 index 0000000000..d03919aa5d --- /dev/null +++ b/learngit/SimbaQ.txt @@ -0,0 +1,4 @@ +多谢您,廖老师! +第一次看一个专业教程这么上瘾!学着学着就欲罢不能了,一口气把整个教程看完了。 +准备看完您的这个git教程后,再学习一下您的Python教程。 +多谢! diff --git a/learngit/SmallHJ.txt b/learngit/SmallHJ.txt new file mode 100644 index 0000000000..2aef5541e3 --- /dev/null +++ b/learngit/SmallHJ.txt @@ -0,0 +1 @@ +Thank you very much! \ No newline at end of file diff --git a/learngit/SomeSuggestions b/learngit/SomeSuggestions new file mode 100644 index 0000000000..9df30065be --- /dev/null +++ b/learngit/SomeSuggestions @@ -0,0 +1,9 @@ +Git is a good tool to control the version +Mr.Liao is a Good Teacher + +Best wishes for you +------ +Mr.Yang + +some suggestion: +可以把git学习的文档放到gitHub上,有些命令或者更简洁的做法,我们可以补充进去啊。 diff --git a/learngit/StromNote.txt b/learngit/StromNote.txt new file mode 100644 index 0000000000..18e9b58994 --- /dev/null +++ b/learngit/StromNote.txt @@ -0,0 +1,335 @@ +摘自廖雪峰的git教程(Thanks Liao) +=============================================================================== +创建版本库: + 版本库又名仓库repository,其实就是一个可以被git管理的目录 + $ mkdir foo 选择一个合适的地方建一个文件夹 + $ cd foo 进入这个文件夹 + $ git init 通过git init命令把当前目录建立成为git仓库 + 建好之后这个目录下回多一个.git目录,这个目录就是git用来跟踪管理版本库的 + 其实也可以使用非控文件夹做git仓库 + + 把文件添加进仓库 + 在foo目录下新建一个readme.txt + $ git add readme.txt 把文件添加到仓库 + $ git commit -m "..." 把文件提交到仓库,并添加说明 + 可以多次add再统一commit + +------------------------------------------------------------------------------- +时光穿梭: + 版本回退: + 使用git statue命令能实时掌握当前git仓库的状态 + $ git statue + 如果你想看看文件被改动了哪些内容,就需要使用git diff命令 + $ git diff + 这里的git diff其实是比较的已经add的和未add的文件之间的差别 + + git会给我们的工作保存快照,这个快照就是commit,所以我们可以随时回到过去 + 使用git log命令来查看历史记录 + $ git log + 使用--pretty=oneline参数可以减少log的输出,使他的每个记录只输出一行 + $ git log --pretty=oneline + 每条记录都会有一个commit id,这条id就表示了这条记录 + git用HEAD表示当前版本,HEAD^表示上一个版本,以此类推HEAD^^...HEAD~100 + 然后就可以使用如下命令回到过去了 + $ git reset --hard HEAD^ + $ git reset --hard 这里commit id只打前几位能区分开来就好 + 使用了git reset命令,HEAD就指向指定的版本,再使用log命令将只能获得当前 + HEAD版本之前的版本 + 所以我们要使用下面的命令,git记录了我们的每次操作 + $ git reflog + 使用这个命令找到比当前版本新的版本的commit id就可以reset回去了 + 总之:log命令可以查看提交历史,reflog可以查看命令历史 + + 工作区和暂存区: + 工作区(work directory)就是我们在电脑里能看到的目录,比复foo文件夹 + 版本库(repository)工作区有一个隐藏目录.git,它不属于工作区,而是git的版本库 + git的版本库里存在了很多东西,其中最重要的就是: + 称为stage(或者叫index)的暂存区 + git为我们创建的第一个分支master + 指向master的指针HEAD + git add就是把文件添加到暂存区 + git commit就是把暂存区文件提交到当前分支 + 因为只有默认创建的master分支,所以commit就是往master分支提交 + 因为每次commit的都是暂存区的内容,所以没有被add的内容不会被commit + 使用如下命令可以比较工作区文件和暂存区文件的异同 + $ git diff -- file + 撤销修改: + 使用如下命令可以撤销工作区的修改 + $ git checkout -- file + 这条命令实际上是把工作区的文件恢复到暂存区的状态 + 即使工作区的状态恢复到上次add,或commit时候的状态 + + 使用下面的命令可以撤销add到暂存区的操作 + $ git reset HEAD file + 这条命令是在提交到暂存区之后又后悔了,使用它使文件恢复到版本库的状态 + 即使工作区的状态恢复到上次commit时候的状态 + 删除文件: + 通常在工作区中删除文件,直接rm即可 + 这时在查看git状态时会提示你工作区中哪些文件被删除了 + 这时,使用如下命令删除版本库中的对应文件 + $ git rm foo.txt + $ git commit + 同样可以使用如下命令,找回该文件 + $ git checkout -- foo.txt + +------------------------------------------------------------------------------- +远程仓库: + git的远程仓库,除了可以自己搭建之外,还可以使用github,本机git和github通信 + 是通过ssh协议加密的,所以需要如下设置(可选): + 1.创建ssh key,如果用户主目录下有.ssh文件夹,且其内有id_rsa和id_rsa.pub + 两个文件可以跳过第一步了,如果没有打开shell,创建ssh key: + $ ssh-keygen -t rsa -C "your_email@example.com" + 2.一切顺利就能创建成功,私钥是id_rsa,公钥是id_rsa..pub,登录github,进入 + Account setting,ssh key页面,然后add ssh key,填上任意title,在key文本里 + 粘贴id_rsa.pub内容,点击啊add key即可完成。 + + 添加远程仓库: + 添加远程仓库先在github创建repository,然后可以克隆到本地或关联本地仓库 + 在git中远程仓库默认叫做origin + 关联本地仓库: + 回到本地的仓库,运行一下命令 + $ git remote add origin git @github.com:somebody/foo.git + 把本地仓库内容推送到远程仓库 + $ git push -u origin master + 这条命令实际上是吧当前分支master推送到远程 + 因为远程库是空的,所以这次推送加上-u选项,git不但把本地master分支 + 推送到远程的master分支,还把两者关联起来,以后的推送拉去就能简化命令 + 以后的推送都可以使用下面的命令来实现 + $ git push origin master + 从远程库中克隆: + 要是从头开发的话,可以先在github创建repository,然后在克隆到本地 + 使用如下命令来克隆到本地 + $ git clone git@github.com:somebody/foo.git + 其实git给出的地址不止一个,还可以使用https://github.com/somebody/foo.git + 其实git是支持多种协议的,默认的git://使用ssh,但也可以使用https等其他协议 + +------------------------------------------------------------------------------- +分支管理: + git无论是创建,切换和删除分支,都只需要不到1秒,无论一个文件还是一万个文件 + 创建与合并分支: + 一开始master分支是一条线,git用master指向最新的提交,再用HEAD指向master,就 + 能确定当前分支,以及当前分支的提交点,每次提交master都会向前移动一小步, + 当我们创建新的分支dev时,git就创建一个新的指针,指向与master相同的指针 + ,再把HEAD指向dev,从现在开始,对工作区的修改和提交就是针对dev分支了,在 + dev上的工作完成后,就可以把dev合并到master上,其实就是把master指针指向d + ev当前的提交,这时就可以把dev分支删除了,由此可见,git的分支操作很快 + + 使用如下命令创建并切换到dev分支,-b就表示创建并切换 + $ git checkout -b dev + 这条命令相当于下面两条 + $ git branch dev + $ git checkout dev + 然后使用git branch查看当前分支,这条命令会列出所有分支,当前分支标有*号 + $ git branch + 在dev上的工作和master相同,这时如果想切换会master,使用如下命令 + $ git checkout master + 现在把dev分支上的内容合并到master,使用如下命令 + $ git merge dev + 注意这个命令用于将指定分支合并到当前分支 + 合并时候就可以删除dev分支了,使用如下命令 + $ git branch -d dev + git鼓励我们用分支来完成任务,这样不会托慢速度而且更安全 + + 解决冲突: + 分支合并也不总是一帆风顺的,有时候master分支和dev分支都在进行开发,两个分支 + 都进行新的commit,而且提交了相同的文件,但是内容不同,这时就不能快速合并 + 需要手动修改冲突文件,使用git statue可以查看冲突文件,修改后在提交就好了 + 使用如下命令能查看分支合并图 + $ git log --graph + $ git log --graph --pretty=oneline --abbrev-commit + + 分支管理策略: + 通常合并分支时,如果可能,git会使用Fast forward模式,但是这种模式下删除分支后, + 会丢失分支信息,如果强制使用Fast forward模式,git会在merge时生成一个 + commit来保存信息 + + 策略: + 1.实际开发中,master分支应该是非常稳定的,仅仅用来发布新版本,平时不 + 能再上面干活 + 2.干活都在dev分支上,dev分支是不稳定的,仅当发布新版本时候把dev分支合并到 + master分支上,然后在master分支上发布1.0版本什么的 + 3.每个小伙伴都在dev分支上干活,每个人都有自己的分支,时不时地往dev分 + 支上合并就好了 + + git分支十分强大,在团队开发中应该充分利用 + 在合并分支时候,加上--no-ff参数就可以使用普通模式合并,合并后的历史有分支, + 能看出曾进做过的合并,而Fast forward合并就看不出曾进做过的合并 + + --no-ff合并: + 普通模式合并,no-ff表示禁用Fast forward + 使用如下命令进行no-ff合并,因为合并生成一个commit,所以加-m参数加说明 + $ git merge --no-ff -m "merge with no-ff" + + bug分支: + git分支管理非常强大,每个bug都可以使用临时分支来解决,合并后就可以删除了 + 一个很常见的bug修复流程: + 首先使用git stash将当前工作区储藏起来,以备日后恢复工作 + $ git stash + 这时又是干净的工作区了,若要在master上修复bug,就在master上建bug分支 + $ git checkout master 切换到master分支 + $ git checkout -b issue-101 创建并切换到bug分支issue-101 + 修复bug完成后,切换到master分支,并完成合并,然后删除bug分支 + $ git checkout mater 切换到master分支 + $ git merge --no-ff issue-101 -m "merge bug fix 101" 合并分支 + $ git branch -d issue-101 删粗bug修复分支 + 切换会dev分支 + $ git checkout dev + 要恢复stash起来的工作区,首先使用下面的命令查看stash list + $ git stash list + 1.要恢复工作区,方法一 + $ git stash apply stash@{0} 恢复stash@{0}存储的工作区 + $ git stash drop stash@{0} 删除stash{0} + 2.要恢复工作区,方法二 + $ git stash pop 恢复工作区,并删除stash + + feature分支: + 开发时,有时候希望添加一些新功能,但我们不希望实验性的代码把主分支弄坏 + 可以创建feature分支,在上面开发,完成后再合并,删粗 + 首先新建一个feature分支 + $ git checkout -b feature-newfun 新建并切换到feature分支 + 开发完成后回到dev分支,准备合并 + $ git checkout dev + 1.如果一切顺利就可以合并并删除feature分支了 + $ git merge --no-ff feature-newfun -m "add new fun" + $ git branch -d feature-newfun + 2.如果这时情况有变,要取消新功能,我们就需要销毁feature分支 + $ git branch -d feature-newfun + 这时会销毁失败,需要强制销毁 + $ git branch -D feature-newfun + 至此删除feature分支完成 + + 多人协作: + 当我们从远程仓库中克隆的时候,git把本地master分支和远程的master分支关联了, + 并且远程仓库的默认名称是origin + 要查看远程仓库,使用如下命令 + $ git remote + 或者使用-v选项显示更详细的信息 + $ git remote -v + 上面会显示可以抓取和推送的git地址,如果没有推送权限将看不到push地址 + + 推送分支: + 推送分支时候,要指定本地分支,这样把该分支推送到远程仓库对应的分支上 + $ git push orgin master + 如果要退送其他分支,比如dev分支 + $ git push orgin dev + 但是,并不一定要把本地分支都推送到远程分支上, + master是主分支,因此要时时刻刻与远程分支同步 + dev是开发分支,团队成员都要在上面工作,因此也要时刻与远程分支同步 + bug分支只用在本地修复bug,没必要推送,除非老板要看你每周修复几个bug + feature分支是否推送,取决于你是否和小伙伴合作在上面开发 + + 总之,分支是否往远程推送,取决于自己,完全可以在本地自己藏着玩 + 通常要合作在上面开发的分支都要推送到远程仓库 + + 抓取分支: + 使用下面的命令从远程库抓取,或者克隆本地库 + $ git clone repository + 从远程库中克隆下来的只有master分支,现在要在dev分支上开发,就要在本地 + 创建远程organ的dev分支 + $ git branch -b dev orgin/dev + 这时你的小伙伴就可以在他本地push到远程了 + 如果你的小伙伴push是碰巧你也push了相同文件呢,这时就会产生冲突 + 这时推送就会失败,这时就要把远程库的代码抓下来解决冲突 + $ git pull + 可能pull失败,因为没有本地dev分支没有和远程dev分支关联 + 这时使用下面的代码来关联 + $ git branch --set-upstream branch-name orgin/branch-name + 来下来之后,常常会有合并冲突,需要手动解决 + 解决后再push就好了 + + 多人合作的工作模式常常是这样的: + 首先可以使用下面的命令推送自己的修改 + $ git push orgin branch-name + 如果推送失败是因为远程分支比你本地的新,使用pull合并 + $ git pull + 如果合并有冲突,需要解决冲突,在本地提交 + 没有冲突或者解决掉冲突后就可以推送了 + $ git push orgin branch-name + + 如果git提示"no tracking information",则说明本地分支没有和远程库的分支 + 关联,使用下面的命令来关联 + $ git branch --set-upstream branch-name orgin/branch-name + +------------------------------------------------------------------------------- +标签管理: + 发布一个版本时,我么常常现在版本库中打一个标签,这样就唯一确定了打标签时候的 + 版本,将来无论什么时候,随时都可以取出打标签的版本,其实就是一个版本快照 + + git的标签也是一个指针,和分支很像,不同的是,分支可以移动,而标签不能移动 + + 创建标签: + 首先切换到要打标签的版本 + $ git checkout master + 然后使用如下的命令打标签 + $ git tag v1.0 + 可以使用如下的命令查看所有标签 + $ git tag + 打标签默认是打在最近的commit上的,如果要给历史版本打标签 + 就要先找到历史的commit id再给它大上 + $ git log --pretty=oneline --abbrev-commit + $ git tag v0.9 633834 + 注意标签不是按照时间排序,而是按照字母排序的 + 使用git tag 查看标签信息 + 还可以创建带说明的标签,使用-a指定标签名,-m指定说明 + $ git tag -a v0.1 -m "this is a tag" 632345 + 还可可以使用-s用私钥签名一个标签 + $ git tag -s v0.2 -m "signed version 0.2 released" f234b3 + 签名使用GPG签名,所以必须先安装了GunPG,并且有gpg密钥对 + + 操作标签: + 删除标签: + $ git tag -d v0.1 + 推送标签到远程 + $ git push origin + 或者可以一次性推送所有本地标签 + $ git push origin --tags + 删除远程标签,要先删本地的,再删远程的 + $ git tag -d v0.1 + $ git push origin :refs/tags/v0.1 + +------------------------------------------------------------------------------- +使用GitHub: + github不仅仅是一个提供git远程仓库的网站,也是一个开源协作社区 + 通过github,我们既可以参与别人的开源项目,别人也可以参与我们的开源项目 + + 在github上可以fork别人的项目到自己的帐号下,再从自己的帐号下clone + 自己的开发要往自己的远程库推送,如果我们改一个bug什么的,可以在github + 上发起pull request,然后就看别人是否接受了 +------------------------------------------------------------------------------- +自定义git: + git有很多配置选项 + 如之前见到的 + $ git config --global user.name "xxx" + $ git config --global user.email "xxx@example.com" + $ git config --global color.ui true + + 忽略特殊文件: + 我们开发时常常需要把一些不想被git管理的文件添加到git管理的文件夹 + 比如java编译厚的.class文件 + 这时在git根目录新建.gitignore文件在里面写忽略规则即可 + https://github.com/github/gitignore这个网站已经为我们提供了各种情况 + 的忽略规则,我们只要适当组合即可 + 配置别名: + git也有alias就像linux的alias,很好用,特别是不能补全命令的windows上 + git config --global alias.st statue + 一个有趣的配置: + git config --global alias.lg "log --color --graph + --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) + %C(bold blue)<%an>%Creset' --abbrev-commit" + 配置git的时候,--global是对当前用户起作用的,不加就是对当前库起作用 + 每个仓库的git配置文件都放在.git/config中 + 每个用户的git配置文件都放在用户主目录的.gitconfig中 + 搭建git服务器: + 1.在linux上搭建git服务器: + $ sudo apt-get install git (sudo yum install git) + $ sudo adduser git + 2.创建证书登录,收集所有需要登录用户的公钥,即id_rsa.pub + 放入/home/git/.ssh/authorized_keys文件里,一行一个 + 3.初始化git仓库,切换到自己指定的git目录执行 + $ sudo git init -bare sample.git 服务器专用的初始化方式 + 4.把git目录owner改为git + $ sudo chown git:git sample.git + 5.禁用git用户shell登录 + 在/etc/passwd文件中把git的登录运行文件改为/usr/bin/git-shell + 这样git服务器就设置好了,可以在自己的电脑上clone了 + $ git clone git@server:/srv/sample.git diff --git a/learngit/Syt.txt b/learngit/Syt.txt new file mode 100644 index 0000000000..9157ed51a4 --- /dev/null +++ b/learngit/Syt.txt @@ -0,0 +1 @@ +感谢廖大神的教程,浅显易懂,写的很好,赞! diff --git a/learngit/TEST b/learngit/TEST new file mode 100644 index 0000000000..d8fd44a4f3 --- /dev/null +++ b/learngit/TEST @@ -0,0 +1 @@ +Test for git diff --git a/learngit/ThanksForHalu126.txt b/learngit/ThanksForHalu126.txt new file mode 100644 index 0000000000..c87c211be9 --- /dev/null +++ b/learngit/ThanksForHalu126.txt @@ -0,0 +1,3 @@ +谢谢你给我的爱,让我入门了Git。 +halu126 +20141023 diff --git a/learngit/Thanks_from_Hennrik.txt b/learngit/Thanks_from_Hennrik.txt new file mode 100644 index 0000000000..806e97bcba --- /dev/null +++ b/learngit/Thanks_from_Hennrik.txt @@ -0,0 +1,9 @@ +Time:21:36 2015/5/1 +Location: Stockholm,Sweden + +Hi Liao, +Thank you for sharing your learning notes of Git, which help me a lot. I hope there will be a lot of excellent blogs from you,and I will so excited to explore them. + +Best regards, + +Hennrik \ No newline at end of file diff --git a/learngit/TianYongwei.txt b/learngit/TianYongwei.txt new file mode 100644 index 0000000000..a88b8bdc6f --- /dev/null +++ b/learngit/TianYongwei.txt @@ -0,0 +1,4 @@ +hello, MR Liao. +Thanks for your git tutorial, I got a lot from it. +Thanks a lot! +--TianYongwei \ No newline at end of file diff --git a/learngit/TireTestFileTwo b/learngit/TireTestFileTwo new file mode 100644 index 0000000000..22f21d10f5 --- /dev/null +++ b/learngit/TireTestFileTwo @@ -0,0 +1 @@ +test file two diff --git a/learngit/Tjuly.txt b/learngit/Tjuly.txt new file mode 100644 index 0000000000..ee4630f16e --- /dev/null +++ b/learngit/Tjuly.txt @@ -0,0 +1 @@ +Thans to Teacher-lao, it's a good doc for our fresh-men \ No newline at end of file diff --git a/learngit/TomorOoO.txt b/learngit/TomorOoO.txt new file mode 100644 index 0000000000..6856f44a79 --- /dev/null +++ b/learngit/TomorOoO.txt @@ -0,0 +1 @@ +I have learned a lot,thank you!!! \ No newline at end of file diff --git a/learngit/WonderdchNote.txt b/learngit/WonderdchNote.txt new file mode 100644 index 0000000000..4158c55fa4 --- /dev/null +++ b/learngit/WonderdchNote.txt @@ -0,0 +1,175 @@ +常用命令 + + +Git 配置 + git config --global +初始化Git + git init +添加文件到GIt仓库 + 添加: git add dir/files example:git add Readme.txt + 提交: git commit -m "commit instruction(本次提交的说明)" +查看仓库当前状态 + git status +查看上一次修改 + git diff +版本回退 + 查看提交日志: git log / git log --pretty=oneline + 版本回退: git reset --hard commit_id git reset --hard HEAD(HEAD当前版本,HEAD^上个版本,HEAD~100上一百个版本) + 重返未来: git reflog 查看命令历史,然后在其中确定commit_id +撤销修改 + 撤销工作区修改: git checkout -- file example: git checkout -- Readme.txt + 撤销暂存区修改: git reset HEAD file 然后 git checkout -- file +删除文件 + 删除本地文件: rm file 然后通过 git status 可以查看删除记录 + 撤销删除本地文件: git checkout -- file + 从git 库删除: git rm file 然后 git commit +同步 + + +上传 + 要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; + +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +下载 + 第一次通过Clone + git clone git@github.com:michaelliao/gitskills.git + git clone git@github.com:UserName/FolderName.git + 平时直接用Sync + +分支操作 + +Git鼓励大量使用分支: + +查看分支:git branch + +创建分支:git branch + +切换分支:git checkout + +创建+切换分支:git checkout -b + +合并某分支到当前分支:git merge + +删除分支:git branch -d + + + +分支策略 + +在实际开发中,我们应该按照几个基本原则进行分支管理: + +首先,master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活; + +那在哪干活呢?干活都在dev分支上,也就是说,dev分支是不稳定的,到某个时候,比如1.0版本发布时,再把dev分支合并到master上,在master分支发布1.0版本; + +你和你的小伙伴们每个人都在dev分支上干活,每个人都有自己的分支,时不时地往dev分支上合并就可以了。 + +所以,团队合作的分支看起来就像这样: + + + +小结: +Git分支十分强大,在团队开发中应该充分应用。 + +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + + +来源: + +其它分支 + +BUG 分支 + 修复bug时,可以另外建立一个bug分支,修改完后切换回master并合并分支,删除bug分支 + 去修复bug前,你要保存当前工作区,通过git stash 修复完成后返回工作区(git stash apply、git stash drop、)git stash pop +Feature分支 + 当为系统添加新功能时可以建立一个Feature分支 + + +多人协作 + + +git remote 查看远程库的信息 + +git remote -v显示更详细的信息 + +git push origin master将本地所有提交推送到远程库的master分支上 + + git push origin dev推送到远程库的dev分支上 + + + + +master分支是主分支,因此要时刻与远程同步; + +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + + + +多人协作的工作模式通常是这样: + +首先,可以试图用git push origin branch-name推送自己的修改; + +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +如果合并有冲突,则解决冲突,并在本地提交; + +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单。 + + +小结 +查看远程库信息,使用git remote -v; + +本地新建的分支如果不推送到远程,对其他人就是不可见的; + +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + + + + + +标签操作 + + + +发布一个版本时,我们通常先在版本库中打一个标签,这样,就唯一确定了打标签时刻的版本。将来无论什么时候,取某个标签的版本,就是把那个打标签的时刻的历史版本取出来。所以,标签也是版本库的一个快照。 + +Git的标签虽然是版本库的快照,但其实它就是指向某个commit的指针(跟分支很像对不对?但是分支可以移动,标签不能移动),所以,创建和删除标签都是瞬间完成的。 + +打新标签 git tag git tag -a v0.1 -m "version 0.1 released" 3628164 -a指定标签名,-m指定说明文字 3628164 指定commit id +查看标签git tag +查看标签信息git show + +小结 +命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; + +git tag -a -m "blablabla..."可以指定标签信息; + +git tag -s -m "blablabla..."可以用PGP签名标签; + +命令git tag可以查看所有标签。 + + +其它操作 + +git log 之后按q键返回正常模式 + +查看commit id:git log --pretty=oneline --abbrev-commit + +当出现分支合并问题后,可以用下面这句查看分支合并图:git log --graph --pretty=oneline --abbrev-commit diff --git a/learngit/XiaosThanks.txt b/learngit/XiaosThanks.txt new file mode 100644 index 0000000000..fbdc6da55e --- /dev/null +++ b/learngit/XiaosThanks.txt @@ -0,0 +1,2 @@ +Thank you for your perfect git tutorial. +Test for the pull request. diff --git a/learngit/YJack.txt b/learngit/YJack.txt new file mode 100644 index 0000000000..b73793a6b4 --- /dev/null +++ b/learngit/YJack.txt @@ -0,0 +1,3 @@ +Hello, Mr Liao. When I meet your blog, I begin to know that GIT is so powerful! It's far more better than SVN. +I'm not so clever as some friends. I spend whole week to understand you lesson. It really helps me. +Thank you from deep of my heart, Mr. Liao! You are such a great man! I wish you a happy life and job! diff --git a/learngit/YiZhuoChen.txt b/learngit/YiZhuoChen.txt new file mode 100644 index 0000000000..e5731fdcf7 --- /dev/null +++ b/learngit/YiZhuoChen.txt @@ -0,0 +1 @@ +The tutorials help me a lot. I love it. Thank you very much. diff --git a/learngit/ZhuXiaobing.txt b/learngit/ZhuXiaobing.txt new file mode 100644 index 0000000000..befc8c7c79 --- /dev/null +++ b/learngit/ZhuXiaobing.txt @@ -0,0 +1 @@ +thank you very much ,the tutorial is very good ,this tutorial gives me plenty of help.thank you angin! diff --git "a/learngit/a - \345\211\257\346\234\254.txt" "b/learngit/a - \345\211\257\346\234\254.txt" new file mode 100644 index 0000000000..3f5aecf5f6 --- /dev/null +++ "b/learngit/a - \345\211\257\346\234\254.txt" @@ -0,0 +1,3 @@ +It's a test. +Thanks. +asdsada \ No newline at end of file diff --git a/learngit/a.txt b/learngit/a.txt new file mode 100644 index 0000000000..1eff8521b2 --- /dev/null +++ b/learngit/a.txt @@ -0,0 +1,6 @@ +It's a test. +Thanks. + + +hello +hehee \ No newline at end of file diff --git a/learngit/aMsgFromMe.txt b/learngit/aMsgFromMe.txt new file mode 100644 index 0000000000..9a702e2b10 --- /dev/null +++ b/learngit/aMsgFromMe.txt @@ -0,0 +1,2 @@ +Thanks, Liao~ +You're so nice~ \ No newline at end of file diff --git a/learngit/a_letter_from_liuweifly b/learngit/a_letter_from_liuweifly new file mode 100644 index 0000000000..b61f608f78 --- /dev/null +++ b/learngit/a_letter_from_liuweifly @@ -0,0 +1,8 @@ +Hi, Mr.Liao + +Thank you for providing this course. It is your course that helps me to know Git and GitHub. + +Thank you again, + + + liuweifly Oct.14th 2014 diff --git a/learngit/a_sponsor.txt b/learngit/a_sponsor.txt new file mode 100644 index 0000000000..466eeb81fb --- /dev/null +++ b/learngit/a_sponsor.txt @@ -0,0 +1,5 @@ +Hi, Mr.Liao + +Thank you for providing this course. It is your course that helps me to know Git and GitHub. + +Thank you again diff --git a/learngit/aaa-lisicong.txt b/learngit/aaa-lisicong.txt new file mode 100644 index 0000000000..a47fdd0a4e --- /dev/null +++ b/learngit/aaa-lisicong.txt @@ -0,0 +1 @@ +Thank you! \ No newline at end of file diff --git a/learngit/ai.txt b/learngit/ai.txt new file mode 100644 index 0000000000..9342a0daba --- /dev/null +++ b/learngit/ai.txt @@ -0,0 +1 @@ +it is too hard. diff --git a/learngit/ai7hoo.txt b/learngit/ai7hoo.txt new file mode 100644 index 0000000000..91418aaefc --- /dev/null +++ b/learngit/ai7hoo.txt @@ -0,0 +1 @@ +Thanks for sharing. :) diff --git a/learngit/aknife.txt b/learngit/aknife.txt new file mode 100644 index 0000000000..f6d5f51d4c --- /dev/null +++ b/learngit/aknife.txt @@ -0,0 +1,3 @@ +test pull request +Thank you! + diff --git a/learngit/allenqi.txt b/learngit/allenqi.txt new file mode 100644 index 0000000000..9a305e21d0 --- /dev/null +++ b/learngit/allenqi.txt @@ -0,0 +1 @@ +Thanks very much! diff --git a/learngit/altaxa.txt b/learngit/altaxa.txt new file mode 100644 index 0000000000..bdadf9b0f7 Binary files /dev/null and b/learngit/altaxa.txt differ diff --git a/learngit/aluckcat.txt b/learngit/aluckcat.txt new file mode 100644 index 0000000000..34ad150330 --- /dev/null +++ b/learngit/aluckcat.txt @@ -0,0 +1,3 @@ +Hey , i am a luckcat from Nanjing . +I am learning GIT from your blog . +Lots of thanks for you . \ No newline at end of file diff --git a/learngit/alvingeek.txt b/learngit/alvingeek.txt new file mode 100644 index 0000000000..5c7b5e0732 --- /dev/null +++ b/learngit/alvingeek.txt @@ -0,0 +1,6 @@ +Dear Liao, + How are you these days? I am so pleased that I have chance to get your Git and python tutorial. I hope you know how I appreciate your help. + I think the tutorial you write is so simply ,clear and cool. your are really a good teacher, I can learn this skill very efficiently. After learn this skill I have a strong desire to do sth helpful for the open source community. + Thank you for you many kindness and I wish you are happy everyday. + Sincerely yours, + Alvin diff --git a/learngit/annging.txt b/learngit/annging.txt new file mode 100644 index 0000000000..6cfbfc3e0a --- /dev/null +++ b/learngit/annging.txt @@ -0,0 +1,3 @@ +I feel so sorry that I can't wirte this in Chinese and My English is pool. + +I write this for test the function of "pull reqest" \ No newline at end of file diff --git a/learngit/azlarsin.txt b/learngit/azlarsin.txt new file mode 100644 index 0000000000..bd51448598 --- /dev/null +++ b/learngit/azlarsin.txt @@ -0,0 +1,3 @@ +hi, michael + + diff --git a/learngit/baokang.txt b/learngit/baokang.txt new file mode 100644 index 0000000000..a17077978a --- /dev/null +++ b/learngit/baokang.txt @@ -0,0 +1 @@ +NICE! \ No newline at end of file diff --git a/learngit/bear.txt b/learngit/bear.txt new file mode 100644 index 0000000000..f331f10278 --- /dev/null +++ b/learngit/bear.txt @@ -0,0 +1,10 @@ +This is a test for pull request +Thank you for your course ,teacher Liao~ +I've learned a lot about git, +and this is my first time to enter the world of github +It is very important to me! +Happy new year ! + + + +i modify this file on local dev \ No newline at end of file diff --git a/learngit/bee1989.txt b/learngit/bee1989.txt new file mode 100644 index 0000000000..084e03c263 --- /dev/null +++ b/learngit/bee1989.txt @@ -0,0 +1 @@ +Thank you for your tutorial! \ No newline at end of file diff --git a/learngit/beiyi.txt b/learngit/beiyi.txt new file mode 100644 index 0000000000..61ee2207ea --- /dev/null +++ b/learngit/beiyi.txt @@ -0,0 +1,5 @@ +感谢廖雪峰给我们贡献了如此浅显易懂的git教程。 +我不是一名程序员,但靠带领别人认识程序世界为职业。 +我希望将来能通过这里所学的知识,把自己的一些学习体会和代码放在github上和大家分享。 + +如果说我对git的学习心得,那就是我把git看作vmware虚拟机快照管理器一样的东西。只不过做快照的对象是文本内容。 diff --git a/learngit/bigbigbug.txt b/learngit/bigbigbug.txt new file mode 100644 index 0000000000..25162e0efc --- /dev/null +++ b/learngit/bigbigbug.txt @@ -0,0 +1 @@ +thank you. diff --git a/learngit/bill.txt b/learngit/bill.txt new file mode 100644 index 0000000000..5ad28e2276 --- /dev/null +++ b/learngit/bill.txt @@ -0,0 +1 @@ +haha diff --git a/learngit/bin-git-id.txt b/learngit/bin-git-id.txt new file mode 100644 index 0000000000..a47fdd0a4e --- /dev/null +++ b/learngit/bin-git-id.txt @@ -0,0 +1 @@ +Thank you! \ No newline at end of file diff --git a/learngit/blastbao.txt b/learngit/blastbao.txt new file mode 100644 index 0000000000..c5ac549826 --- /dev/null +++ b/learngit/blastbao.txt @@ -0,0 +1,2 @@ +Very thanks! +I have learned Git through your blog. diff --git a/learngit/bobhuang-github-id.txt b/learngit/bobhuang-github-id.txt new file mode 100644 index 0000000000..dda6d31a9f --- /dev/null +++ b/learngit/bobhuang-github-id.txt @@ -0,0 +1,2 @@ +Michael Liao,I have learned how to make full use of git after reading your teaching blog. +Thank you very much! You are my idol. diff --git a/learngit/borisliu.txt b/learngit/borisliu.txt new file mode 100644 index 0000000000..b87e1f441c --- /dev/null +++ b/learngit/borisliu.txt @@ -0,0 +1 @@ +很好的教程,谢谢! diff --git "a/learngit/branch\345\221\275\344\273\244 \345\260\217\347\273\223" "b/learngit/branch\345\221\275\344\273\244 \345\260\217\347\273\223" new file mode 100644 index 0000000000..96ebe5421f --- /dev/null +++ "b/learngit/branch\345\221\275\344\273\244 \345\260\217\347\273\223" @@ -0,0 +1,27 @@ + +谢谢雪峰老师的经典教程!这两天我边看边练习. +这是我第一次在github上测试pull request. + +下面是我一边看教程,一边实践,然后总结出来的一些有关分支(branch)的命令: + +创建分支:git branch +查看分支:git branch + +删除分支: +git branch -d 删除本地已经commit的分支 +git branch -D 删除本地还未commit的分支 +加强说明:在B分支状态下,无法删除B分支.必须切换到其他分支状态下,才能删除B分支. + +切换分支:git checkout +创建+切换分支:git checkout -b + +合并某分支到当前分支:git merge + +协作完成项目时,为了把远程分支的更新同步(pull)到本地相应的分支,需先设置好二者的链接: +git branch --set-upstream origin/ + +...... + +暂时先写这些.若有不足之处,恳请朋友们斧正:) + + diff --git a/learngit/bravery-github-id.txt b/learngit/bravery-github-id.txt new file mode 100644 index 0000000000..4da99bbbf2 --- /dev/null +++ b/learngit/bravery-github-id.txt @@ -0,0 +1,2 @@ +http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137628548491051ccfaef0ccb470894c858999603fedf000 +This is a excellent git tutorial diff --git a/learngit/bupt-Jerry.thank b/learngit/bupt-Jerry.thank new file mode 100644 index 0000000000..f4f95520a8 --- /dev/null +++ b/learngit/bupt-Jerry.thank @@ -0,0 +1,7 @@ +Dear Liao: + I am a graduate student from Beijing Univ. of Posts and Telecom. I followed your weibo and knew you are also graduated form BUPT. I learned a lot from your blog teaching Git. It is amazing that I find most of technique blogs are written by allumnus of our school. + + +Best wished! +Have a nice day! +Jiarui Fang diff --git a/learngit/buptgao.txt b/learngit/buptgao.txt new file mode 100644 index 0000000000..264350b9cf --- /dev/null +++ b/learngit/buptgao.txt @@ -0,0 +1 @@ +廖雪峰老实的git教程真是生动有趣,学起来轻松又愉快,希望出更多更好的精品教程 diff --git a/learngit/bupttest.txt b/learngit/bupttest.txt new file mode 100644 index 0000000000..c5f9ef2adb --- /dev/null +++ b/learngit/bupttest.txt @@ -0,0 +1 @@ +really nice to have liao's lesson! thank u! \ No newline at end of file diff --git a/learngit/caike007.txt b/learngit/caike007.txt new file mode 100644 index 0000000000..6c61518b20 --- /dev/null +++ b/learngit/caike007.txt @@ -0,0 +1,3 @@ +I am a UI designer, good at visual design, interaction design, but coding is not my strengh, +github is a good place to draw lessons and improve myself quickly, +thanks for your intruduction. \ No newline at end of file diff --git a/learngit/caimaoy@gmail.com b/learngit/caimaoy@gmail.com new file mode 100644 index 0000000000..59176a00bc --- /dev/null +++ b/learngit/caimaoy@gmail.com @@ -0,0 +1,11 @@ +# -*- coding: UTF-8 -*- + +''' +Last modified time: 2015-01-04 11:51:08 +Edit time: 2015-01-04 11:51:53 +File name: caimaoy@gmail.com +Edit by caimaoy +''' + +if __name__ == '__main__': + print 'THX' diff --git a/learngit/candywxt.txt b/learngit/candywxt.txt new file mode 100644 index 0000000000..1767f6eae8 --- /dev/null +++ b/learngit/candywxt.txt @@ -0,0 +1,3 @@ +感谢~~ +教程很好!浅显易懂!非常感谢! +昨天并不是用git bash pr 的,今天练习了一下在git bash里面敲命令行,发现也很方便! \ No newline at end of file diff --git a/learngit/candywxtlearnmore.txt b/learngit/candywxtlearnmore.txt new file mode 100644 index 0000000000..de2d3c16b9 --- /dev/null +++ b/learngit/candywxtlearnmore.txt @@ -0,0 +1,24 @@ +回忆一下今天学到的几个命令 +cd e:/ 到指定的目录下 +mkdir 建立一个版本库 +pwd 查看当前目录位置 +git init 初始化一个仓库 +git add file 添加一个文件 +git commit -m "写上你每一次的修改" +git status 查看工作区状态 +git log 查看历史记录 +git log -graph 以图形化形式查看记录 +git log --pretty=onelinte 简化记录 +git branch 查看分支 +git checkout -b bev 创建bev分支并切换到bev分支下 +git merge dev 合并分支 +git merge --no-ff -m "禁止快速合并" dev +git remote add origin git@github.com:candywxt/XXX 关联一个仓库 +git push -u origin master 首次push +git push origin master 以后push +git clone git@github.com:candywxt/XXX.git clone一个仓库 +rm 删除文件 +git rm 删除版本库中的文件 +git stash 保护现场 +git stash list 保险现场的list +git stash pop 恢复现场并且删除stash diff --git a/learngit/caolicheng.txt b/learngit/caolicheng.txt new file mode 100644 index 0000000000..fcd4cbc374 --- /dev/null +++ b/learngit/caolicheng.txt @@ -0,0 +1 @@ +大神你好,我学习了,谢谢你 \ No newline at end of file diff --git a/learngit/captain_xk.txt b/learngit/captain_xk.txt new file mode 100644 index 0000000000..f09e1314d9 --- /dev/null +++ b/learngit/captain_xk.txt @@ -0,0 +1,2 @@ +Thank you for your tutorial,Michael! +我表示看到一个家伙做了一份非常棒的笔记,这里表示强烈推荐收藏,就是cloudstone.txt这份文件,非常感谢! \ No newline at end of file diff --git a/learngit/captainwong.txt b/learngit/captainwong.txt new file mode 100644 index 0000000000..cb514b3e72 --- /dev/null +++ b/learngit/captainwong.txt @@ -0,0 +1,4 @@ +Thx for you contribution! +I'm a fresh bird on git, thx your outstanding articles for helping me learn git. +Respects +captainwong \ No newline at end of file diff --git a/learngit/carlos121493.txt b/learngit/carlos121493.txt new file mode 100644 index 0000000000..b385a7c565 --- /dev/null +++ b/learngit/carlos121493.txt @@ -0,0 +1 @@ +感谢老师教的内容,让我对git以及版本发布有了比较深的认识,通过操作了解git的原理,这让在工作中用不到git的同学有了很好的途径认识,希望能被pull request \ No newline at end of file diff --git a/learngit/cassie_git.txt b/learngit/cassie_git.txt new file mode 100644 index 0000000000..ccdb6105e4 --- /dev/null +++ b/learngit/cassie_git.txt @@ -0,0 +1,4 @@ +This is my first learn to pull request git. +I love reading your git course. +I find learning git is so interesting. +I hope you could allow my pull request diff --git a/learngit/changshun b/learngit/changshun new file mode 100644 index 0000000000..dc6a77b785 --- /dev/null +++ b/learngit/changshun @@ -0,0 +1,3 @@ +I am a graduate student in Xiamen University. +I am not good at coding. +Thank u for writing this tutorial. diff --git a/learngit/chenglong365.txt b/learngit/chenglong365.txt new file mode 100644 index 0000000000..a04e0e328e --- /dev/null +++ b/learngit/chenglong365.txt @@ -0,0 +1,4 @@ +测试pull request +================== + +非常棒的Git教程,之前也学习过好几次Git,都是学的晕晕乎乎,始终搞不明白。直到接触到廖老师的Git教程,短短几个小时,浅显易懂,step by step的实践,开始喜欢上Git了。原来Git这么棒。多谢廖老师。Good work。 \ No newline at end of file diff --git a/learngit/chenleilei.txt b/learngit/chenleilei.txt new file mode 100644 index 0000000000..7163de1774 --- /dev/null +++ b/learngit/chenleilei.txt @@ -0,0 +1 @@ +Thanks Mr Liao for git. diff --git a/learngit/chenzhijun.txt b/learngit/chenzhijun.txt new file mode 100644 index 0000000000..68d9b8c78a --- /dev/null +++ b/learngit/chenzhijun.txt @@ -0,0 +1 @@ +some sentence will throw exception : eg:git remote add..... there will be .... diff --git a/learngit/christine.txt b/learngit/christine.txt new file mode 100644 index 0000000000..d808774751 --- /dev/null +++ b/learngit/christine.txt @@ -0,0 +1 @@ +Thanks for your sharing. Your course is awesome. \ No newline at end of file diff --git a/learngit/chunyu.txt b/learngit/chunyu.txt new file mode 100644 index 0000000000..040cf679fb --- /dev/null +++ b/learngit/chunyu.txt @@ -0,0 +1,5 @@ +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. + +By yangchunyu 2015,5,25 diff --git a/learngit/cloudstone.txt b/learngit/cloudstone.txt new file mode 100644 index 0000000000..6644d25ce6 --- /dev/null +++ b/learngit/cloudstone.txt @@ -0,0 +1,44 @@ + +git init 创建版本库 +git add 添加文件到缓冲区 +git commit -m ‘xxx’ 提交到本地仓库 +git status 查看当前目录状态 +git diff 查看文件变化的内容 +git reset --hard HEAD^ 回退到上一版本, git reset --hard HEAD^^ 回退到上上版本,git reset --hard HEAD~100 回退到上100个版本,git reset —hard 回退到指定版本 +git reflog 查看历史版本,如果有需要,随后可以根据显示的commit id进行回退 +git add后如果又修改了,此时git commit只会提交add过的版本,后面修改的不会提交 +git checkout -- revert文件到add过或最新的版本,先add的版本,再最新的版本 +git reset HEAD 可以撤销git add的版本 +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 + +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 + +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + + +git rm 会同时删除仓库里的文件和本地文件,但是在提交之前,还是可以通过git reset HEAD && git checkout —- 恢复文件 +git rm 相当于本地rm 再git add +git remote add origin git@server-name:path/repo-name.git 关联一个远程库 +git push -u origin master第一次推送master分支的所有内容 +git push origin master推送最新修改(对远程库非第一次) +git branch 查看分支 +git branch 创建分支 +git checkout 切换分支 +git checkout -b 创建+切换分支 +git merge 合并某分支到当前分支 +git branch -d 删除分支 +git log —graph 查看分支合并图 +git stash 保存工作现场 +git stash list 查看保存的stash +git stash apply stash@{n} 恢复指定的stash +git stash pop stash@{n} 恢复现场并删除该stash +如果一个分支没有被合并过,git branch -d feature 会被友情提醒,需要通过git branch -D feature 强行删除 +git tag 新建一个标签,默认为HEAD,也可以指定一个commit id; +git tag -a -m "blablabla..."可以指定标签信息; + +git tag -s -m "blablabla..."可以用PGP签名标签; +git tag可以查看所有标签。 +git push origin 可以推送一个本地标签; +git push origin --tags可以推送全部未推送过的本地标签; +git tag -d 可以删除一个本地标签; +git push origin :refs/tags/可以删除一个远程标签。 \ No newline at end of file diff --git a/learngit/codeplayer2org.txt b/learngit/codeplayer2org.txt new file mode 100644 index 0000000000..b99e78d1b7 --- /dev/null +++ b/learngit/codeplayer2org.txt @@ -0,0 +1 @@ +作者写的这本git教程生动有趣,相比其他的git教程,如git magic、pro git等容易理解的多,能够快速上手并在项目中实际使用。谢谢。 diff --git a/learngit/coderZdg.txt b/learngit/coderZdg.txt new file mode 100644 index 0000000000..ce4b3a9625 --- /dev/null +++ b/learngit/coderZdg.txt @@ -0,0 +1 @@ +Really Thankyou , liao! diff --git a/learngit/coneo.txt b/learngit/coneo.txt new file mode 100644 index 0000000000..561b34f7a1 --- /dev/null +++ b/learngit/coneo.txt @@ -0,0 +1,5 @@ +朋友开始推荐的一个git教程就是这个,忘了存,后来发现在百度搜“git教程”,出现的第一个链接就是雪峰的站。 +接触git应该是两年前了,那是在大学的时候,当时是想玩玩github才接触的,到现在git算是用的比较频繁。但是 +git的功能用的其实不多,因为主要都是在github上自己写写东西,并没有实际参与到开源中去。(都是题外话了) + +话说回来,这个教程写的特别棒,通俗易懂,对git的整个特性都有了了解,期待在以后有更多的实践。 diff --git a/learngit/csyangbinbin.txt b/learngit/csyangbinbin.txt new file mode 100644 index 0000000000..0db9e69e15 --- /dev/null +++ b/learngit/csyangbinbin.txt @@ -0,0 +1 @@ +so simple GIT lesson! diff --git a/learngit/cuihao0532 b/learngit/cuihao0532 new file mode 100644 index 0000000000..4fbcef1530 --- /dev/null +++ b/learngit/cuihao0532 @@ -0,0 +1,2 @@ +之前看过这个git教学系列,但没有坚持下来。 +这两天重新拾起了这个教学,咱一个! diff --git a/learngit/cuihongbo.txt b/learngit/cuihongbo.txt new file mode 100644 index 0000000000..b3ff0144b0 --- /dev/null +++ b/learngit/cuihongbo.txt @@ -0,0 +1,4 @@ +I'm a zol phper +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. \ No newline at end of file diff --git a/learngit/cuimingliang.txt b/learngit/cuimingliang.txt new file mode 100644 index 0000000000..a67a7bc12c --- /dev/null +++ b/learngit/cuimingliang.txt @@ -0,0 +1,2 @@ +enjoy your interesting git tutorial, and i have a little suggestion, if a beginner mistake for the url of origin when typing "git remote add +origin xxxxxx" then he cant use the origin to push anything, if he doesnt how to remove it ~ thank your wonderful narratives ~ diff --git a/learngit/cx.txt b/learngit/cx.txt new file mode 100644 index 0000000000..7263c01a88 --- /dev/null +++ b/learngit/cx.txt @@ -0,0 +1 @@ +Great git tutotial help me one day to be familiar with git. \ No newline at end of file diff --git a/learngit/daleiyang.txt b/learngit/daleiyang.txt new file mode 100644 index 0000000000..31e92cb085 --- /dev/null +++ b/learngit/daleiyang.txt @@ -0,0 +1 @@ +感谢! \ No newline at end of file diff --git a/learngit/daoxunchen.txt b/learngit/daoxunchen.txt new file mode 100644 index 0000000000..83ea4f982a --- /dev/null +++ b/learngit/daoxunchen.txt @@ -0,0 +1,5 @@ +Thank you very much! +This is the best learning guide I have ever seen. +Have a nice day!!! + +Bye! diff --git a/learngit/darkHorse.txt b/learngit/darkHorse.txt new file mode 100644 index 0000000000..669f5b1483 --- /dev/null +++ b/learngit/darkHorse.txt @@ -0,0 +1,5 @@ +因为廖老师的这个浅显易懂的Git教程,让我这个SVN使用者两天时间就上手了git,真是受益匪浅啊~ +掌握了这些充分必要的Git命令再结合Pro Git的中文教程,从此我不会再用SVN管理项目了。 +廖老师的Git教程真的是良心之作呀,向您致敬! + +PS:向"极客之王"Linus致敬,这是必须的~ diff --git a/learngit/david-liao.txt b/learngit/david-liao.txt new file mode 100644 index 0000000000..344c4cb665 --- /dev/null +++ b/learngit/david-liao.txt @@ -0,0 +1,3 @@ +Hi, Michael +This guide of Git is awesome! +This file is for testing pull request. diff --git a/learngit/davidcr-github-id.txt b/learngit/davidcr-github-id.txt new file mode 100644 index 0000000000..bbade02f9f --- /dev/null +++ b/learngit/davidcr-github-id.txt @@ -0,0 +1 @@ +仅仅是为了测试用的 diff --git a/learngit/deedzhouy.txt b/learngit/deedzhouy.txt new file mode 100644 index 0000000000..edcafce39d --- /dev/null +++ b/learngit/deedzhouy.txt @@ -0,0 +1 @@ +感谢您的教程,对GIT小白帮助很大,必须赞助一下。嘿嘿!! diff --git a/learngit/devmidai.txt b/learngit/devmidai.txt new file mode 100644 index 0000000000..e7f1057034 --- /dev/null +++ b/learngit/devmidai.txt @@ -0,0 +1,2 @@ +这是我见过最好的一个Git课程,终于算是懂了!!! +赞助了20元,谢谢廖老师。 \ No newline at end of file diff --git a/learngit/dhn.txt b/learngit/dhn.txt new file mode 100644 index 0000000000..f556d03824 --- /dev/null +++ b/learngit/dhn.txt @@ -0,0 +1,2 @@ +hello git +thank you! \ No newline at end of file diff --git a/learngit/dhs789520.txt b/learngit/dhs789520.txt new file mode 100644 index 0000000000..1b0ca810d6 --- /dev/null +++ b/learngit/dhs789520.txt @@ -0,0 +1,18 @@ +对一个医生来讲 + +学习计算机已经很不错 + +学习编程已经了了 + + +学习编程的时候还在学习 软件工程,比如git 这样的,几乎找不到同行了 + + +且学且珍惜,谢谢廖老师 + + +如果有一天,我开源项目可以提升自己20%的薪水,会再次来感谢你 + + +你的教程做的非常的好,一步一步跟着教程来,就很容易学git了 + diff --git a/learngit/dongorigin.txt b/learngit/dongorigin.txt new file mode 100644 index 0000000000..dea17ea817 --- /dev/null +++ b/learngit/dongorigin.txt @@ -0,0 +1 @@ +非常感谢您的Git与Python教程,仅仅赞助无法表达谢意。如果可能的话,希望可以帮您编写git教程的Android版。 diff --git a/learngit/draem0507.txt b/learngit/draem0507.txt new file mode 100644 index 0000000000..3f592bf185 --- /dev/null +++ b/learngit/draem0507.txt @@ -0,0 +1,5 @@ +thanks a lot. +用过了多年svn,半年前开始使用git来开发管理。 +之前都是使用sourcetree来进行git的管理,极少用到git 命令来完成。 +年前,刚好有时间,偶遇你的这篇教程,很nice。 +对git感兴趣的可以看下这篇文章:http://www.jianshu.com/p/25647b9920b7 diff --git a/learngit/drice888888.txt b/learngit/drice888888.txt new file mode 100644 index 0000000000..95c22301bf --- /dev/null +++ b/learngit/drice888888.txt @@ -0,0 +1 @@ +The first try +2 diff --git a/learngit/dupengtao.txt b/learngit/dupengtao.txt new file mode 100644 index 0000000000..26c4a12b64 --- /dev/null +++ b/learngit/dupengtao.txt @@ -0,0 +1 @@ +thanks for your guide! \ No newline at end of file diff --git a/learngit/einverne.md b/learngit/einverne.md new file mode 100644 index 0000000000..ec16969720 --- /dev/null +++ b/learngit/einverne.md @@ -0,0 +1,14 @@ +git add [-a] +git status +git commit -m "text" +git push origin master +git reset --soft HEAD^ HEAD~2 +git log +git branch +git checkout +git checkout -b "branchname" +git tag -a tagname -m "text" +git merge + + +.gitignore \ No newline at end of file diff --git a/learngit/einzbern.txt b/learngit/einzbern.txt new file mode 100644 index 0000000000..ebdb9202db --- /dev/null +++ b/learngit/einzbern.txt @@ -0,0 +1 @@ +thank you! diff --git a/learngit/emma-github-id.txt b/learngit/emma-github-id.txt new file mode 100644 index 0000000000..c2d1d8e8f1 --- /dev/null +++ b/learngit/emma-github-id.txt @@ -0,0 +1,4 @@ +Hi Michael, +I started to learn git three days ago. Your tutorial is funny and makes it much more easier. Thanks a lot. +Cheers, +Emma diff --git a/learngit/ewoshow-github-id.txt b/learngit/ewoshow-github-id.txt new file mode 100644 index 0000000000..c44b8bb419 --- /dev/null +++ b/learngit/ewoshow-github-id.txt @@ -0,0 +1 @@ +test github \ No newline at end of file diff --git a/learngit/feikaifeng.txt b/learngit/feikaifeng.txt new file mode 100644 index 0000000000..1459943078 --- /dev/null +++ b/learngit/feikaifeng.txt @@ -0,0 +1 @@ +谢谢博主的精彩博文,之前对Git的概念一直很模糊,今天看了您的文章后对Git有了比较明确的认识。谢谢。 diff --git a/learngit/fkaking.txt b/learngit/fkaking.txt new file mode 100644 index 0000000000..d9d8ec9ad0 --- /dev/null +++ b/learngit/fkaking.txt @@ -0,0 +1,3 @@ +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. diff --git a/learngit/fkdtz.txt b/learngit/fkdtz.txt new file mode 100644 index 0000000000..ad0c0b5bae --- /dev/null +++ b/learngit/fkdtz.txt @@ -0,0 +1,2 @@ +my github-id is fkdtz,my name is lisong,my email is +595375808@qq.com diff --git a/learngit/fl0wjacky.txt b/learngit/fl0wjacky.txt new file mode 100644 index 0000000000..5be6f1d636 --- /dev/null +++ b/learngit/fl0wjacky.txt @@ -0,0 +1,3 @@ +hello,Michael Liao. +I teach myself programming from 3 years ago. +Thank for your jobs. diff --git a/learngit/flyingpang.py b/learngit/flyingpang.py new file mode 100644 index 0000000000..67d10ab86e --- /dev/null +++ b/learngit/flyingpang.py @@ -0,0 +1,2 @@ +#coding:utf-8 +Thank you for your git tutorial ! I'm a new programer. diff --git a/learngit/freealvin.txt b/learngit/freealvin.txt new file mode 100644 index 0000000000..b1c8dd6ef6 --- /dev/null +++ b/learngit/freealvin.txt @@ -0,0 +1 @@ +Thanks for sharing. \ No newline at end of file diff --git a/learngit/freestyle4568.txt b/learngit/freestyle4568.txt new file mode 100644 index 0000000000..93a6ed5559 --- /dev/null +++ b/learngit/freestyle4568.txt @@ -0,0 +1,5 @@ +thank you for your kindness and good lessons +i get lots of knowledge from your lessons, learn python and practise again and again +i contact with git through your git lessons, and it is very understandable +now i learn from the git. And i can contribute my strength to our open-source world! +THANK YOU diff --git a/learngit/fulinux.txt b/learngit/fulinux.txt new file mode 100644 index 0000000000..94904dee16 --- /dev/null +++ b/learngit/fulinux.txt @@ -0,0 +1,3 @@ +感谢廖雪峰给我们贡献了如此浅显易懂的git教程。 +写的实在太好了,我已经想身边的同时推荐阅读了。 +再次更新 diff --git a/learngit/galaxybing-demo.txt b/learngit/galaxybing-demo.txt new file mode 100644 index 0000000000..58fe02ae1f --- /dev/null +++ b/learngit/galaxybing-demo.txt @@ -0,0 +1,3 @@ +本地化版本控制 文件补丁 +Subversion 文件快照 +Git 镜像 \ No newline at end of file diff --git a/learngit/gdouchufu.txt b/learngit/gdouchufu.txt new file mode 100644 index 0000000000..7b0f79aca2 --- /dev/null +++ b/learngit/gdouchufu.txt @@ -0,0 +1,204 @@ +安装Git + * 在Linux上安装Git: + * Debian或Ubuntu: sudo apt-get install git + * 其它Linux通过源码安装git: + 先从Git官网下载源码,然后解压,依次输入: + ./config,make,sudo make install + * 在windows上安装Git: + * msysgit是Windows版的Git,从http://msysgit.github.io/下载 + * Tortoisegit是git的客户端 + * 安装完设置:(--global参数,表示你这台机器上所有的Git仓库都会使用这个配置) + $ git config --global user.name "Your Name" + $ git config --global user.email "email@example.com" + * git --version + +创建版本库 + * 创建文件夹learngit,用来放置版本库 + * $ git init + 把这个目录变成Git可以管理的仓库 + * $ git add readme.txt + 编写一个readme.txt文件,放到learngit目录下,通过命令将文件添加到仓库 + * $ git commit -m "wrote a readme file" + 把文件提交本地到仓库 + +时光机穿梭 + * 查看版本库的状态:(将要被提交的修改包括了什么) + * 修改readme.txt,使用以下命令: + * $ git status + * $ git diff readme.txt + * $ git add readme.txt + * $ git commit -m "add distributed" + * 版本回退 + * $ git log 查看提交历史,以便确定要回退到哪个版本 + $ git log --pretty=oneline 可以减少输出信息 + * $ git reset --hard commit_id 在版本的历史之间穿梭 + 上一个版本就是HEAD^,上上一个版本就是HEAD^^,往上100个版本写成HEAD~100 + * $ git reflog 查看命令历史,以便确定要回到未来的哪个版本 + * 工作区和暂存区 + * 工作区(Working Directory):就是你在电脑里能看到的目录,比如learngit文件夹就是一个工作区 + * 版本库(Repository):工作区有一个隐藏目录.git,这个是Git的版本库。 + * Git的版本库里存了很多东西,其中最重要的就是称为stage(或者叫index)的暂存区, + 还有Git为我们自动创建的第一个分支master,以及指向master的一个指针叫HEAD。 + * 文件往Git版本库里添加的时候,是分两步执行的: + * 第一步是用git add把文件添加进去,实际上就是把文件修改添加到暂存区; + * 第二步是用git commit提交更改,实际上就是把暂存区的所有内容提交到当前分支。 + * 简单理解为:需要提交的文件修改通通放到暂存区,然后一次性提交暂存区的所有修改。 + * 管理修改 + * Git管理的是修改,而不是文件 + * 每次修改,如果不add到暂存区,那就不会加入到commit中 + * 撤销修改 + * 把readme.txt文件在工作区的修改全部撤销,有两种情况: + * 一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态: + * $ git checkout -- readme.txt + * 一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态: + * $ git reset HEAD readme.txt //把暂存区的修改撤销掉(unstage),重新放回工作区 + * $ git checkout -- readme.txt //丢弃工作区的修改 + * 删除文件 + * $ git rm test.txt (删除也是修改,将修改信息提交到暂存区) + * $ git checkout -- test.txt //撤销删除 + * $ git commit -m "remove test.txt" //从版本库中删除该文件 + +远程仓库 + * 设置SSH的私钥和密钥 + * 第1步:创建SSH Key + $ ssh-keygen -t rsa -C "youremail@example.com" + * 第2步:登陆GitHub + 打开“Account settings”,“SSH Keys”页面; + 点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容 + * 在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,id_rsa.pub是公钥 + * 添加远程仓库 + * $ git remote add origin git@github.com:gdouchufu/learngit.git + 把一个已有的本地仓库与之关联,然后,把本地仓库的内容推送到GitHub仓库 + * $ git push -u origin master + 把本地库的所有内容推送到远程库上 + (第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支, + 还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。) + * 从远程仓库克隆 + * $ git clone git@github.com:gdouchufu/gitskills.git + * Git支持多种协议,包括https,默认的git://使用ssh,通过ssh支持的原生git协议速度最快 + +分支管理 + * 创建与合并分支 + * $ git checkout -b dev //创建并切换到dev分支,相当于: + $ git branch dev + $ git checkout dev + * $ git branch + 查看当前分支 + * $ git checkout master + 切换回master分支 + * $ git merge dev + * 把dev分支的工作成果合并到master分支上 + * Fast-forward 是“快进模式”,也就是直接把master指向dev的当前提交,合并速度非常快。 + * $ git branch -d dev + 删除dev分支 + * git鼓励使用分支完成某个任务,合并后再删掉分支,这和直接在master分支上工作效果是一样的,但过程更安全! + * 解决冲突 + * $ git log --graph --pretty=oneline --abbrev-commit + --graph 查看分支合并图,--abbrev-commit 只显示commitID的前7位 + (出现冲突时手动更改冲突文件,把冲突文件add到stage后commit,即可fix冲突) + * 分支管理策略 + * Merge made by the 'recursive' strategy. + * 合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息; + * 如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。 + * $ git merge --no-ff -m "merge with no-ff" dev + * --no-ff参数,表示禁用Fast forward + * 因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 + * 分支策略的基本原则 + * master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活 + * 干活都在不稳定的的dev分支上,发布版本新时,再把dev分支合并到master上,在master分支发布1.0版本 + * Bug分支 + * $ git stash + 把当前工作现场“储藏”起来,等以后恢复现场后继续工作 + statsh : 隐藏,藏匿;贮藏;〈英〉停止 + * $ git stash list + 查看保存的工作现场列表 + * 恢复工作现场的2个方法: + * 1、用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除 + * 2、用git stash pop,恢复的同时把stash内容也删了 + * $ git stash apply stash@{0} + 多次stash后恢复的时候,先用git stash list查看,然后恢复指定的stash + * 强制删除分支 + $ git branch -D feature-vulcan + * 多人协作 + * $ git remote //查看远程仓库信息 + * $ git remote -v //显示更详细的信息 + * 推送分支 + * 哪些分支需要推送到远程仓库,哪些不需要? + * $ git push origin master //master分支是主分支,因此要时刻与远程同步; + * $ git push origin dev //dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + * feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + * push失败时,先 git pull ,在本地合并后手动解决冲突,再推送 + * 抓取分支 + * $ git pull + 抓取远程仓库的最新版到当前分支 + * $ git checkout -b dev origin/dev + 创建远程origin的dev分支到本地 + * $ git branch --set-upstream dev origin/dev + 设置dev和origin/dev的链接 + * $ git push origin dev + 将本地的dev分支push到远程的dev分支上 + +标签管理 + * 创建标签 + * $ git tag + 查看所有标签(标签不是按时间顺序列出,而是按字母排序的) + * $ git tag v1.0 + 在最新提交的commit上打标签为v1.0 + * $ git tag v0.9 6224937 + 在commit id为6224937的提交上打标签 + * $ git show v0.9 + 查看标签信息 + * $ git tag -a v0.1 -m "version 0.1 released" 3628164 + 创建带有说明的标签,用-a指定标签名,-m指定说明文字 + * $ git tag -s v0.2 -m "signed version 0.2 released" fec145a + 通过-s用私钥签名一个标签,签名采用PGP签名,必须先安装gpg(GnuPG) + * 操作标签 + * $ git tag -d v0.1 + 删除本地标签 + * $ git push origin v1.0 + 推送某个标签到远程 + * $ git push origin --tags + 一次性推送全部尚未推送到远程的本地标签 + * 删除已经推送到远程的标签 + * 先从本地删除:$ git tag -d v0.9 + * 再从远程删除:$ git push origin :refs/tags/v0.9 +使用GitHub + * 在GitHub上,可以任意Fork开源仓库; + * 自己拥有Fork后的仓库的读写权限; + * 可以推送pull request给官方仓库来贡献代码。 + + +自定义Git + * $ git config --global color.ui true + * 让Git显示颜色,让命令输出看起来更醒目 + * --global参数是全局参数,也就是这些命令在这台电脑的所有Git仓库下都有用 + * 忽略特殊文件 + * Git工作区的根目录下创建一个特殊的.gitignore文件,把要忽略的文件名填进去,Git就会自动忽略这些文件 + * 所有配置文件可以直接在线浏览:https://github.com/github/gitignore + * 配置别名 + * $ git config --global alias.st status + 用git st代替git status + * 用co表示checkout,ci表示commit,br表示branch + * $ git config --global alias.co checkout + * $ git config --global alias.ci commit + * $ git config --global alias.br branch + * $ git config --global alias.unstage 'reset HEAD' + $ git reset HEAD test.py --> $ git unstage test.py + * $ git config --global alias.last 'log -1' + $ git last //显示最近一次的提交 + * git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" + 丧心病狂! 方便地查看git log ... + * 搭建Git服务器 + * 第一步,安装git: + $ sudo apt-get install git + * 第二步,创建一个git用户,用来运行git服务: + $ sudo adduser git + * 第三步,创建证书登录: + 收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个 + * 第四步,初始化Git仓库: + 先选定一个目录作为Git仓库,假定是/srv/sample.git,在/srv目录下输入命令:$ sudo git init --bare sample.git + 把owner改为git : $ sudo chown -R git:git sample.git + * 第五步,禁用shell登录: + 编辑/etc/passwd文件,将git:x:1001:1001:,,,:/home/git:/bin/bash 改为:git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell + * 第六步,克隆远程仓库: + $ git clone git@server:/srv/sample.git diff --git a/learngit/genius001.txt b/learngit/genius001.txt new file mode 100644 index 0000000000..e8243cfd2b --- /dev/null +++ b/learngit/genius001.txt @@ -0,0 +1,2 @@ +your git tutorial is simple and easy to learn. +I will donate your guy for some money:) diff --git a/learngit/git-command.md b/learngit/git-command.md new file mode 100644 index 0000000000..a4537461d6 --- /dev/null +++ b/learngit/git-command.md @@ -0,0 +1,146 @@ +#Git教程 笔记 +> 教程链接:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 + +##创建版本库 ++ `git init`:将当前目录变为Git管理的仓库 ++ `git add `:把文件添加到仓库(stage中) ++ `git commit -m "版本描述"`:把文件按提交到仓库 + +--------------------- +##时光机穿梭 ++ `git status`:显示仓库当前状态 ++ `git diff `:展示文件详细修改内容 +###版本回退 ++ `git log`:显示从最近到最远的提交日志 + + --pretty=oneline:以单行形式显示提交日志 ++ `git reset --hard commit_id`:回退/前进到commit_id指向的版本 ++ `git reset --hard HEAD^`:回退到上一版本 ++ `git log`:查看提交历史 ++ `git reflog`:查看各个版本的commit_id + +###管理修改 ++ git 管理的是修改,而非文件。 ++ 第一次修改 -> git add -> 第二次修改 -> git commit + +###撤销修改 ++ `git checkout -- `:丢弃工作区的修改,返回最近一次add/commit时的文件状态 ++ `git reset HEAD `:丢弃暂存区的修改 + +###删除文件 ++ `git rm `:从版本库中删除文件 + +-------------------- +##远程仓库 + +###添加远程库 +1. 登陆GitHub,“Create a new repository” +2. 添加远程库:`git remote add origin git@github.com:/.git` +3. 推送并关联本地master分支:`git push -u origin master` +4. 提交master分支修改到远程库:`git push origin master` + +###从远程库克隆 ++ `git clone git@github.com:/.git` ++ GitHub支持ssh/https协议 + +--------------------- +##分支管理 + +###创建和合并分支 ++ `git branch `:创建分支 ++ `git branch`:查看分支 ++ `git checkout `:切换分支 ++ `git checkout -b `:创建+切换分支 ++ `git merge `:合并某分支到当前分支 ++ `git branch -d `:删除分支 + +###解决冲突 ++ 当Git无法自动合并分支时,就必须首先解决冲突。解决冲突后,再提交,合并完成 ++ `git log --graph`:看到分支合并图 + +###分支管理策略 +1. `git merge `:`fast forward`模式合并,删除分支,分支信息被丢弃 +2. `git merge --no-ff`:普通模式合并,合并后历史有分支,可通过`git log --graph`看到分支合并记录 + +###Bug分支 ++ `git stash`:储存当前工作现场 ++ `git stash list`:列出所有stash ++ `git stash apply`:恢复最近一次储存的stash ++ `git stash drop`:删除最近一次储存的stash ++ `git stash pop`:恢复+删除最近一次stash ++ `git stash stash@{num}`:恢复指定stash + +###feature分支 ++ `git branch -D `:强行删除没有被合并的分支 + +###多人协作 ++ `git remote -v`:查看远程库的详细信息 ++ `git checkout -b dev origin/dev`:创建远程origin的dev分支到本地 ++ `git branch --set-upstream dev origin/dev`:建立本地分支和远程分支的关联 ++ `git pull`:抓取远程的新提交 ++ `git push origin branch-name`:从本地推送分支 + +--------------------- +##标签管理 ++ 是指向某个commit的指针 ++ 标签不能移动 ++ 创建和删除标签都是瞬间完成的 + +###创建标签 ++ `eg:git tag v1.0` ++ `git tag`:列出所有标签(按字母排序) ++ `git tag `:新建一个标签,默认为HEAD,也可以指定一个commit id ++ `git tag -a -m "description":指定标签信息 ++ `git show `:查看标签信息 + +###操作标签 ++ `git push origin `:推送本地标签到远程库 ++ `git push origin --tags`:推送全部未推送过的本地标签 ++ `git tag -d `:删除本地标签 ++ `git push origin :refs/tags/`:删除远程标签 + +--------------------- +##使用GitHub ++ 自己拥有`Fork`后的仓库的读写权限 ++ 可以推送`pull request`给官方仓库来贡献代码 + +--------------------- +##自定义Git ++ `git config --global color.ui true`:让Git显示颜色 + +###忽略特殊文件 +1. `.gitignore`:配置要忽略的文件 +2. `https://github.com/github/gitignore`:`.gitignore`文件模板 + +###配置别名 ++ 别名是命令的缩写 ++ 例子: + 1. `git config --global alias.st status`:配置status别名为st + 2. `git config --global alias.co checkout`: + 3. `git config --global alias.ci commit`: + 4. `git config --global alias.br branch`: + 5. `git config --global alias.unstage 'reset HEAD'`: + 6. `git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"`: ++ 配置文件: + 1. `.git/config`:仓库的Git配置文件 + 2. `.gitconfig`:当前用户的Git配置文件,放在用户主目录下 + +--------------------- +##搭建Git服务器 +1. 安装git:`sudo apt-get install git` +2. 创建git用户:`sudo adduser git` +3. 创建证书登录:搜集登陆用户公钥(id_rsa.pub)文件,导入`/home/git/.ssh/authorized_keys`文件,一行一个 +4. 初始化Git仓库 + + `sudo git init --bare sample.git` + + `sudo chown R git:git sample.git`:修改裸仓库owner,防止其他用户篡改工作区 +5. 禁用shell登陆(git-shell一登陆就自动退出) + + `vi /etc/passwd` + + `git:x:........:/bin/bash`-->`git:x:......:/usr/bin/git-shell` +6. 克隆远程仓库,本地运行,修改后推送 + + `git clone git@server:/srv/sample.git` + + `git push` +7. 要方便管理公钥,用Gitosis +8. 要像SVN那样变态地控制权限,用Gitolite + +======= + +------------------ diff --git a/learngit/git-tool.md b/learngit/git-tool.md new file mode 100644 index 0000000000..4933bd4993 --- /dev/null +++ b/learngit/git-tool.md @@ -0,0 +1,6 @@ +## 推荐几款chrome上的github插件 +---------- + +- [Octotree](https://github.com/buunguyen/octotree):Browser extensions to display GitHub code in tree format. +- [GistBox](https://chrome.google.com/webstore/detail/gistbox-desktop/pdjgfbgklbmmigkmmdbbhfchdldngkml) :GistBox is the best interface to Github Gists. Organize your snippets with labels. Edit your code. Search by description. All in one speedy app. +- [GistBox Clipper](https://chrome.google.com/webstore/detail/gistbox-clipper/cejmhmbmafamjegaebkjhnckhepgmido):GistBox Clipper is the companion extension to GistBox, the most beautiful way to organize code snippets. It allows a user to create a GitHub Gist from any page on the web. diff --git a/learngit/git-vi-test b/learngit/git-vi-test new file mode 100644 index 0000000000..2994d226a9 --- /dev/null +++ b/learngit/git-vi-test @@ -0,0 +1 @@ +the use of git is interesting diff --git a/learngit/git@github.com-dangweili.txt b/learngit/git@github.com-dangweili.txt new file mode 100644 index 0000000000..9553eb124c --- /dev/null +++ b/learngit/git@github.com-dangweili.txt @@ -0,0 +1 @@ +Thank you for your work ! \ No newline at end of file diff --git a/learngit/git_learning_wrote b/learngit/git_learning_wrote new file mode 100644 index 0000000000..2a736c40dd --- /dev/null +++ b/learngit/git_learning_wrote @@ -0,0 +1,10 @@ +1, git inti +2, touch readme.txt +3, git status +4, git add readme.txt +5, git status +6, git commit -m "add readme.txt file" +7, repeat the abvoe steps to create LICENSE file +8, git remote add original git@github.com:andyChenHuaYing/learngit.git +9, git remote push -u origin master +0, visit github to observe the repository's change. diff --git a/learngit/git_note.md b/learngit/git_note.md new file mode 100644 index 0000000000..30cc14a3b2 --- /dev/null +++ b/learngit/git_note.md @@ -0,0 +1,111 @@ +# Git与GitHub + +标签(空格分隔): ReadingNote + +[toc] + +----------------------- +## 常用命令 +- 开始时,克隆 +``` +$ git clone git@github.com:yourname/resp.git # 仅master +$ git checkout -b dev origin/dev # 新建并克隆分支 +``` +- 查看状态 +``` +$ git status +$ git diff #add之前 +$ git log [--pretty=oneline] +$ git log -p -1 # 查看最近一次提交的修改 +$ git reflog # 查看使用过的命令 +``` +- 完成后,add与commit +``` +$ git add . +$ git commit -m "It's the comment." +``` +- 版本回退 +``` +$ git reset --hard HEAD^^ # 回退两个版本 +$ git reset --hard HEAD~100 # 回退100个版本 +``` +- 撤销修改 +``` +$ git checkout -- # 撤销工作区中的修改 +$ git reset HEAD # 撤销add +``` +- 添加标签(release) +``` +$ git tag v0.1 [0f50c4] #为[0f50c4]设置标签v0.1 +$ git tag # 查看已有标签 +$ git show v0.1 # 查看v0.1 +$ git push origin --tags # 推送所有标签 +$ git tag -d v0.1 # 删除标签 +``` +-------------------------- +## 分支管理 +> git的分支管理,是文件指针的变化;git鼓励使用分支 + +### 基本操作 +- 创建分支 +``` +$ git checkout -b dev # 创建分支dev +``` +- 切换分支 +``` +$ git checkout dev # 切换到dev +``` +- 查看分支 +``` +$ git branch +``` +- 合并分支 +``` +$ git merge [--no-ff -m "merge with no-ff"] dev +``` +- 删除分支 +``` +$ git branch -d dev +``` +- 保存现场 +``` +$ git stash +$ git stash pop +``` +### 解决冲突 +- 有冲突时,无法合并,需要手工解决冲突 +- 通过`git status`查看冲突的文件 +- 打开冲突的文件,git已经标记了冲突的位置 + +###多人协作 +> 出现冲突时,先pull到本地,合并后再push + +- 远程提交 +``` +$ git push [-u] origin master # 第一次使用需要[-u] +``` +- 建立关联 +``` +$ git branch --set-upstream dev origin/dev +``` +- 本地同步 +``` +$ git pull +``` +-------------------------- +## 第一次使用的基本配置 +- 产生`密钥` +``` +$ ssh-keygen -t rsa -C "your_email@youremail.com" +``` +- 在github中注册`公钥`(`~/.ssh/id_rsa.pub`) +- 设置`username`与`email` +``` +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +``` +----------------------- +## 参考资料 +1. [廖雪峰的官方网站 - Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000) +1. [Wuyuan's Blog](http://wuyuans.com/2012/05/github-simple-tutorial/) +1. [快乐&&平凡 - CSDN.NET](http://blog.csdn.net/wh_19910525/article/details/8128916) diff --git a/learngit/git_test.txt b/learngit/git_test.txt new file mode 100644 index 0000000000..8138d0d7e9 --- /dev/null +++ b/learngit/git_test.txt @@ -0,0 +1 @@ +看了大神的git教程,来试验一下pull request!>_< \ No newline at end of file diff --git a/learngit/github_id b/learngit/github_id new file mode 100644 index 0000000000..cdeec60f4e --- /dev/null +++ b/learngit/github_id @@ -0,0 +1 @@ +..... diff --git a/learngit/githubpassok748.txt b/learngit/githubpassok748.txt new file mode 100644 index 0000000000..0d84f7210c --- /dev/null +++ b/learngit/githubpassok748.txt @@ -0,0 +1,5 @@ +非常感谢大神让我入门Git! + +内容通俗易懂,堪比《图灵》系列作者写作水准! + +BZW: 我也是业务产品经理HOHO~ \ No newline at end of file diff --git a/learngit/glivia.txt b/learngit/glivia.txt new file mode 100644 index 0000000000..b47ee294e3 --- /dev/null +++ b/learngit/glivia.txt @@ -0,0 +1 @@ +It's really good! Thanks! diff --git a/learngit/gnoygn1.txt b/learngit/gnoygn1.txt new file mode 100644 index 0000000000..7dc354d0d4 --- /dev/null +++ b/learngit/gnoygn1.txt @@ -0,0 +1 @@ +非常好的git教材,按着事例做学习的很快,多谢廖老师! diff --git a/learngit/gordon-learngit.md b/learngit/gordon-learngit.md new file mode 100644 index 0000000000..973b3e10a2 --- /dev/null +++ b/learngit/gordon-learngit.md @@ -0,0 +1 @@ +gordon fork file diff --git a/learngit/gqtc.txt b/learngit/gqtc.txt new file mode 100644 index 0000000000..13f24137ec --- /dev/null +++ b/learngit/gqtc.txt @@ -0,0 +1,2 @@ +非常感谢您的git教程,要是赞助方式支持网银的话,我一定会赞助的。 +thank you very much! diff --git a/learngit/gratitude.txt b/learngit/gratitude.txt new file mode 100644 index 0000000000..c3a38a780a --- /dev/null +++ b/learngit/gratitude.txt @@ -0,0 +1 @@ +thank you very much!!! \ No newline at end of file diff --git a/learngit/gulisha.txt b/learngit/gulisha.txt new file mode 100644 index 0000000000..ccd790032c --- /dev/null +++ b/learngit/gulisha.txt @@ -0,0 +1 @@ +thank you ! \ No newline at end of file diff --git a/learngit/guoyalun.md b/learngit/guoyalun.md new file mode 100644 index 0000000000..757fbf97dd --- /dev/null +++ b/learngit/guoyalun.md @@ -0,0 +1,3 @@ +感谢给我们贡献了如此浅显易懂的git教程。 +真正的感觉自己git 可以轻松入门了! + diff --git a/learngit/guoziali.txt b/learngit/guoziali.txt new file mode 100644 index 0000000000..101876b1c2 --- /dev/null +++ b/learngit/guoziali.txt @@ -0,0 +1,2 @@ +test pull request + thanks for you help diff --git a/learngit/guzhuyi b/learngit/guzhuyi new file mode 100644 index 0000000000..270c611ee7 --- /dev/null +++ b/learngit/guzhuyi @@ -0,0 +1 @@ +hello, world! diff --git a/learngit/gyb.txt b/learngit/gyb.txt new file mode 100644 index 0000000000..819cc44976 --- /dev/null +++ b/learngit/gyb.txt @@ -0,0 +1 @@ +haha \ No newline at end of file diff --git a/learngit/gydmercy.txt b/learngit/gydmercy.txt new file mode 100644 index 0000000000..bf1ad444ab --- /dev/null +++ b/learngit/gydmercy.txt @@ -0,0 +1 @@ +廖老师讲的很详细,很棒,谢谢老师 \ No newline at end of file diff --git a/learngit/haokee.txt b/learngit/haokee.txt new file mode 100644 index 0000000000..8ca0dd4b7c --- /dev/null +++ b/learngit/haokee.txt @@ -0,0 +1 @@ +我倒是觉得git的学习起点是比较高的,但是按照作者的网页一点点敲,相信会有意想不到的收获,顶作者还有他的主页 http://www.liaoxuefeng.com。做的很棒,加油!!! diff --git a/learngit/haolidong.txt b/learngit/haolidong.txt new file mode 100644 index 0000000000..4407009d0d --- /dev/null +++ b/learngit/haolidong.txt @@ -0,0 +1 @@ +这是来自一个git新手的推送,测试教程中所说的fork,clone,pull request的操作方法 diff --git a/learngit/hejy12.txt b/learngit/hejy12.txt new file mode 100644 index 0000000000..9ff3882359 --- /dev/null +++ b/learngit/hejy12.txt @@ -0,0 +1 @@ +Hello, git ! diff --git a/learngit/hello b/learngit/hello new file mode 100644 index 0000000000..5e196d2ef1 --- /dev/null +++ b/learngit/hello @@ -0,0 +1,7 @@ +public class main +{ + public static void main(String [] args) + { + System.out.println("hello world!"); + } +} diff --git a/learngit/hello world b/learngit/hello world new file mode 100644 index 0000000000..a0409f6af7 --- /dev/null +++ b/learngit/hello world @@ -0,0 +1 @@ +中午好啊...... diff --git a/learngit/hello-world pull request b/learngit/hello-world pull request new file mode 100644 index 0000000000..cab0f0eb82 --- /dev/null +++ b/learngit/hello-world pull request @@ -0,0 +1,4 @@ + +This is the first pull request called hello-world ! + +Thanks! diff --git a/learngit/helloToXueFeng.txt b/learngit/helloToXueFeng.txt new file mode 100644 index 0000000000..ce246f0c31 --- /dev/null +++ b/learngit/helloToXueFeng.txt @@ -0,0 +1,7 @@ +My feeling of learning MichaelLiao's Lesson: + +Thanks for your asesome Git Lesson. It help us open the eyes to the open source project world. I use two day's time to learn how to use git through your leasson. I really like your word of your Git Lesson and it's so easy to understand. + +All in all, I hope you have a better life and write more useful and high-qualified lesson. + +Thank you again. diff --git a/learngit/hellogit.txt b/learngit/hellogit.txt new file mode 100644 index 0000000000..404a44e60e --- /dev/null +++ b/learngit/hellogit.txt @@ -0,0 +1 @@ +hello,git,you are my friend. diff --git a/learngit/helloworld b/learngit/helloworld new file mode 100644 index 0000000000..5d308e1d06 --- /dev/null +++ b/learngit/helloworld @@ -0,0 +1 @@ +aaaa diff --git a/learngit/henulwj.txt b/learngit/henulwj.txt new file mode 100644 index 0000000000..4f9927370a --- /dev/null +++ b/learngit/henulwj.txt @@ -0,0 +1,2 @@ +Thank you very much! +I have learned how to handle git. diff --git a/learngit/hexianjie.txt b/learngit/hexianjie.txt new file mode 100644 index 0000000000..0affa86004 --- /dev/null +++ b/learngit/hexianjie.txt @@ -0,0 +1,2 @@ +感谢老师的教程, +希望老师越来越好! diff --git a/learngit/hezhping.txt b/learngit/hezhping.txt new file mode 100644 index 0000000000..303d5c2307 --- /dev/null +++ b/learngit/hezhping.txt @@ -0,0 +1,4 @@ +廖老师: + 您好! + 首先感谢你的无私奉献,我先后看过你的python教程和Git教程,受益匪浅。 + diff --git a/learngit/hitoy.txt b/learngit/hitoy.txt new file mode 100644 index 0000000000..8630e4fe74 --- /dev/null +++ b/learngit/hitoy.txt @@ -0,0 +1,2 @@ +This is hito from http://www.hitoy.org +This for liaoxuefeng's git course diff --git a/learngit/hjc1702.txt b/learngit/hjc1702.txt new file mode 100644 index 0000000000..18141e0a3c --- /dev/null +++ b/learngit/hjc1702.txt @@ -0,0 +1,2 @@ +按照您的git教程一步步使用,感觉非常好。非常清晰. +谢谢您的教程~ diff --git a/learngit/hmlv b/learngit/hmlv new file mode 100644 index 0000000000..b94bc9c3cf --- /dev/null +++ b/learngit/hmlv @@ -0,0 +1,2 @@ +hello michaelliao: + thank you very much. diff --git a/learngit/hongqi.txt b/learngit/hongqi.txt new file mode 100644 index 0000000000..0affa86004 --- /dev/null +++ b/learngit/hongqi.txt @@ -0,0 +1,2 @@ +感谢老师的教程, +希望老师越来越好! diff --git a/learngit/huang-feature.txt b/learngit/huang-feature.txt new file mode 100644 index 0000000000..74c2be3d2e --- /dev/null +++ b/learngit/huang-feature.txt @@ -0,0 +1 @@ +I am Bob Huang,Nice to meet you! diff --git a/learngit/huangyue5207.txt b/learngit/huangyue5207.txt new file mode 100644 index 0000000000..914f35289e --- /dev/null +++ b/learngit/huangyue5207.txt @@ -0,0 +1 @@ +it's a very good toturial of git,it's very useful for me.thank you! diff --git a/learngit/hustyjy@qq.com.txt b/learngit/hustyjy@qq.com.txt new file mode 100644 index 0000000000..0f8ff38c23 --- /dev/null +++ b/learngit/hustyjy@qq.com.txt @@ -0,0 +1 @@ +教程很强大,谢谢。 diff --git a/learngit/hzdavid2013@gmail.txt b/learngit/hzdavid2013@gmail.txt new file mode 100644 index 0000000000..f156500d0f --- /dev/null +++ b/learngit/hzdavid2013@gmail.txt @@ -0,0 +1,2 @@ +thand you very much . +you article is very good. diff --git a/learngit/hzlu-github.py b/learngit/hzlu-github.py new file mode 100644 index 0000000000..5270d53d65 --- /dev/null +++ b/learngit/hzlu-github.py @@ -0,0 +1 @@ +print "hello, thank you for your GIT Tutorial." \ No newline at end of file diff --git a/learngit/hztgcl1986.txt b/learngit/hztgcl1986.txt new file mode 100644 index 0000000000..a2960a905f --- /dev/null +++ b/learngit/hztgcl1986.txt @@ -0,0 +1 @@ +Git教程非常棒!!! diff --git a/learngit/iinsonia.txt b/learngit/iinsonia.txt new file mode 100644 index 0000000000..a396b6b8fb --- /dev/null +++ b/learngit/iinsonia.txt @@ -0,0 +1 @@ +thanks for your lesson! diff --git a/learngit/iwang.txt b/learngit/iwang.txt new file mode 100644 index 0000000000..dfc89baa65 --- /dev/null +++ b/learngit/iwang.txt @@ -0,0 +1,7 @@ +Mr.Liao: + +Your tuition is the best Git_for_freshman that I have read ever. + +Thanks a lot. + +from iwang@tencent.com diff --git a/learngit/jackchan0419.txt b/learngit/jackchan0419.txt new file mode 100644 index 0000000000..03d9a27b42 --- /dev/null +++ b/learngit/jackchan0419.txt @@ -0,0 +1 @@ +Git pull test. diff --git a/learngit/jackie.txt b/learngit/jackie.txt new file mode 100644 index 0000000000..1b2b093a1f --- /dev/null +++ b/learngit/jackie.txt @@ -0,0 +1 @@ +pull request test diff --git a/learngit/jacks808.txt b/learngit/jacks808.txt new file mode 100644 index 0000000000..58b0971f0c --- /dev/null +++ b/learngit/jacks808.txt @@ -0,0 +1,11 @@ +this is a git learn note from keen (find me on git:github.com/jacks808) +1.git add [file name] +2.git commit -m "msg" +3.git push origin dev +4.git checkout dev-keen : create a new branch and switch to it +5.git checkout dev : switch to branch dev +6.git merge dev-keen : merge dev-keen branch to branch in use(now is dev) + +THANK FOR YOU COURSE! + +YOU CAN FIND ME AT jacks808@163.com diff --git a/learngit/jaminzhang.txt b/learngit/jaminzhang.txt new file mode 100644 index 0000000000..c7c299e770 --- /dev/null +++ b/learngit/jaminzhang.txt @@ -0,0 +1,3 @@ +Thank you very much, Teacher Liao. +Your git course explains the profound in simple terms. +I like it. diff --git a/learngit/jason.txt b/learngit/jason.txt new file mode 100644 index 0000000000..ebdb9202db --- /dev/null +++ b/learngit/jason.txt @@ -0,0 +1 @@ +thank you! diff --git a/learngit/jiangkui.txt b/learngit/jiangkui.txt new file mode 100644 index 0000000000..89937b38dd --- /dev/null +++ b/learngit/jiangkui.txt @@ -0,0 +1,102 @@ +貌似都用英语表达谢意。。。 英语太菜了。。。 +花了大概3天左右的时间练习完这个教程,廖老师写的教程确实不错。。。 +点个赞 + +顺便带上一个粗糙的笔记。 用的马克飞象,跟markdown差不多。 + +============================================================ + + +#《Git 教程》 廖雪峰 + +[原文地址][1] + +**注意事项** : +- **中文目录**:如果你使用Windows系统,为了避免遇到各种莫名其妙的问题,请确保目录名(包括父目录)不包含中文。 +- **管理范围**:所有的版本控制系统,其实只能跟踪文本文件的改动,比如 TXT 文件,网页,所有的程序代码等,Git也不例外。而图片、视频这些二进制文件,没法跟踪文件的变化,只能把二进制文件每次改动串起来。 Microsoft 的 Word 格式是二进制格式。所以也没法弄。 +- **其他**:千万不要使用 Windows 自带的记事本编辑任何文本文件,原因是 Microsoft 开发记事本的团队,在每个文件开头添加了 0xefbbbf(十六进制)的字符。 +- **分支管理策略**:Git 默认会用 `Fast forward` 模式,这种模式下,删除分之后,会丢掉分支信息。禁用 `Fast forward`模式,就能看到分支信息。`git merge --no-ff -m "说明" <分支名称>` `--no-ff` 表示禁用 `Fast forward`。 + +------------------------------ + +[TOC] + +##Git的优势 +- 在本地工作完全不用考虑远程库的存在,svn在没有联网时是拒绝干活的。有网络的时候,再把本地库提交推送以下就完成了同步。 + +##Linux命令 +- mkdir:创建目录 +- cd: +- pwd:显示当前目录 + +##Git 命令 + +| 命令 | 说明 | +| :------ | :-------------- | +|git init | 初始化 | +|git add `` | 添加文件到仓库 `文件必须在仓库目录下,可反复多次使用,添加多个文件` | +|git commit -m '' | 本次提交的说明 | +|git status | 工作区的状态 | +|git diff HEAD -- `` | 查看工作区与版本库里最新版本的区别`HEAD表示当前版本` | +|git reset --hard commit_id | 回退到历史版本 | +|git log | 查看`提交`历史 | +|git reflog | 查看`命令`历史 | +|git checkout -- `` | 丢弃工作区的修改 | +|git rm `` | 删除 | +||| +|git push | 把当前分支`master`推送到远程仓库 | +|git push -u origin master | 第一次推送 master 分支的所有内容 | +|git push origin `【tagname | --tags】 后者表示推送所有标签`) | 推送标签到远程库 | +|git push origin :refs/tags/`` | 可以删除一个远程标签 | +||| +|git remote add ...`百度` | 关联远程库 | +|git lone `https://github.com/jiangkui/gitskills2`| 克隆仓库到本地,Git支持多种协议,包括`https`,但通过 `ssh` 支持的原生 `git`协议速度最快| +||| +|git branch | 查看分支 | +|git branch `` | 创建分支 | +|git branch -d `` | 删除分支 | +|git branch -D `` | 强行删除没有合并过的分支 | +|git branch --set-upstream `本地分支名称` origin/`远程分支名称` | 建立本地分支和远程分支的关联 | +||| +|git checkout `` | 切换分支 | +|git checkout -b `` | 创建+切换分支 | +|git checkout -b `本地分支名称` origin/`远程分支名称` | 在本地创建和远程对应的分支(`本地分支名称与远程分支名称最好一致`) | +|git merge `` | 合并某分支到当前分支 | +|git log --graph | 看到分支合并图 | +|git stash | 存储当前修改的内容 | +|git stash list | 查看存储的工作现场 list | +|git stash pop | 取出并删除存储的第一个内容 | +|git stash apply | 恢复存储的内容但不删除 | +|git remote -v | 查看远程库信息 | +|git push origin `分支名称` | 从本地库推送分支 | +|git pull | 抓取远程的新提交 | +|git tag `` `[版本号,默认 HEAD]` | 用户新建一个标签 | +|git tag -a `` -m `blablabla` | 指定标签信息 | +|git tag | 查看所有标签 | +|git tag -d v0.1| 删除标签| + + + +##名词概念 +**工作区**:git项目里,电脑能看到的目录(文件夹)。 +**版本库**:工作区有一个隐藏目录`.git`,这个不算工作区,是Git 的版本库。 +git 的版本库里存了很多东西,其中最重要的就是 stage(或者叫 index)的暂存区,还有Git 为我们自动创建的第一个分支`master`,以及指向`master`的第一个指针叫`HEAD`。 +![Alt text](./1428395768401.png) + +在向Git 版本库里添加的时候,分两步: +第一步用`git add`把文件添加进去,实际上把文件修改添加到暂存区; +第二步用`git commit`提交,就是把暂存区的所有内容提交到当前分支。 + +`暂存区是Git 非常重要的概念,弄明白了暂存区,就弄明白了Tig的都很多操作到底干了什么。` + +每次修改,如果不add到暂存区,那就不会加入到 `commit`中。 + + +[1]:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 + + + +============================================================ + + + jiangkui 20115-04-09 \ No newline at end of file diff --git a/learngit/jiucai.txt b/learngit/jiucai.txt new file mode 100644 index 0000000000..78a4a7a966 --- /dev/null +++ b/learngit/jiucai.txt @@ -0,0 +1,4 @@ +the best profit of git is more branch will not add repository file size ,just record changes and index. + + +-- wrote by jiucai at 2014-09-17 diff --git a/learngit/johnleo.txt b/learngit/johnleo.txt new file mode 100644 index 0000000000..259079a5b1 --- /dev/null +++ b/learngit/johnleo.txt @@ -0,0 +1 @@ +Thank you for your tutorial. diff --git a/learngit/junfengwang.txt b/learngit/junfengwang.txt new file mode 100644 index 0000000000..0fddcc0fde --- /dev/null +++ b/learngit/junfengwang.txt @@ -0,0 +1 @@ +谢谢峰的教程 马上就要看完git教程 python也看了一半了 希望再出点其他技术教程,如 node.js, 谢谢 \ No newline at end of file diff --git a/learngit/justlearn.txt b/learngit/justlearn.txt new file mode 100644 index 0000000000..07d918fcd1 --- /dev/null +++ b/learngit/justlearn.txt @@ -0,0 +1 @@ +long long ago , i try my best to learn git by one book ,it is too heavy and difficult for me to learn . and a month later ,i forgot what i learned .util now ,i really like teacher liao,i learned so much from you.thank you! diff --git a/learngit/justsayhi.txt b/learngit/justsayhi.txt new file mode 100644 index 0000000000..cfbd95b142 --- /dev/null +++ b/learngit/justsayhi.txt @@ -0,0 +1 @@ +我就四 试一试。。哈哈 谢谢 liaolaoshi \ No newline at end of file diff --git a/learngit/jyc.txt b/learngit/jyc.txt new file mode 100644 index 0000000000..bf0f4d2bb9 --- /dev/null +++ b/learngit/jyc.txt @@ -0,0 +1 @@ +i am jyc,thank you very much diff --git a/learngit/k0becheng-1.txt b/learngit/k0becheng-1.txt new file mode 100644 index 0000000000..51b885a4b6 --- /dev/null +++ b/learngit/k0becheng-1.txt @@ -0,0 +1,2 @@ +昨天下午刚开始看您的教程,果然比pro git更适合我们这些个刚入门的用户呢! +暂时对git的使用还不是太熟悉,等熟悉了有比较好的理解我会通过博客的方式和大家共享。 \ No newline at end of file diff --git a/learngit/kid b/learngit/kid new file mode 100644 index 0000000000..b6ca084731 --- /dev/null +++ b/learngit/kid @@ -0,0 +1 @@ +kid is a testfile diff --git a/learngit/kingone-id.txt b/learngit/kingone-id.txt new file mode 100644 index 0000000000..5dde773b1f --- /dev/null +++ b/learngit/kingone-id.txt @@ -0,0 +1 @@ +I like Git very much,and I want to improve my Git Skills as soon as possible is I want to do now. diff --git a/learngit/km_test.txt b/learngit/km_test.txt new file mode 100644 index 0000000000..05e69ab056 --- /dev/null +++ b/learngit/km_test.txt @@ -0,0 +1 @@ +testing pull. Thx for liaoxuefeng \ No newline at end of file diff --git a/learngit/koala.txt b/learngit/koala.txt new file mode 100644 index 0000000000..af6dd70c47 --- /dev/null +++ b/learngit/koala.txt @@ -0,0 +1,2 @@ +im koala +Thanks diff --git a/learngit/ksir.txt b/learngit/ksir.txt new file mode 100644 index 0000000000..235b037f8f --- /dev/null +++ b/learngit/ksir.txt @@ -0,0 +1,3 @@ +很好的学习教程,生动形象 +利用下班的时间很快就学会上手使用了。 +感谢作者! diff --git a/learngit/lalaticao.txt b/learngit/lalaticao.txt new file mode 100644 index 0000000000..110760acc9 --- /dev/null +++ b/learngit/lalaticao.txt @@ -0,0 +1 @@ +Merci beaucoup! \ No newline at end of file diff --git a/learngit/lcjingdi@gmail.com b/learngit/lcjingdi@gmail.com new file mode 100644 index 0000000000..d71e468d9e --- /dev/null +++ b/learngit/lcjingdi@gmail.com @@ -0,0 +1 @@ +你的教程比较浅显易懂很受用谢谢!!! diff --git a/learngit/learn_git.txt b/learngit/learn_git.txt new file mode 100644 index 0000000000..75fce32735 --- /dev/null +++ b/learngit/learn_git.txt @@ -0,0 +1,3 @@ +this is a request pull + +on GITHUB diff --git a/learngit/learn_git_thx.txt b/learngit/learn_git_thx.txt new file mode 100644 index 0000000000..573f761af4 --- /dev/null +++ b/learngit/learn_git_thx.txt @@ -0,0 +1 @@ +thanks for your blog diff --git a/learngit/learn_manual.txt b/learngit/learn_manual.txt new file mode 100644 index 0000000000..4c170e731f --- /dev/null +++ b/learngit/learn_manual.txt @@ -0,0 +1,175 @@ + +0.安装完成后,还需要最后一步设置,在命令行输入: + +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +因为Git是分布式版本控制系统,所以,每个机器都必须自报家门:你的名字和Email地址。你也许会担心,如果有人故意冒充别人怎么办?这个不必担心,首先我们相信大家都是善良无知的群众,其次,真的有冒充的也是有办法可查的。 + +1.git status +是对比 版本库中的 branch :master 中的文件 和 working directory中的文件 + +2.若一样 : + $ git status + # On branch master + to commit (working directory clean + 若不一样: + 对比是否提交到index:stage中 暂时区 + 此时可以将working directory 中的文件用命令 git checkout 和标准的master中的一样--变化的是working directory + + 提交add 到stage中 则提示 是否commit + 此时 可以用 git reset HEAD to unstage + + +3.为什么Git比其他版本控制系统设计得优秀, + 因为Git跟踪并管理的是修改,而非文件。 + “git commit”只负责把暂存区的修改提交了 + +4."git checkout -- ..." to discard changes in working directory) + 是让这个文件回到最近一次git commit或git add时的状态。 + + +5.git reset命令既可以回退版本,也可以把暂存区的修改回退到工作区 + + git checkout -- readme.txt + git reset HEAD readme.txt HEAD原来在working directory处,当git add后 ,HEAD指向stage + git reset --hard HEAD^ HEAD在commit后指向master + +6.你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要一点设置: + + $ ssh-keygen -t rsa -C "youremail@example.com" + -t type Specify type of key to create. + -C comment Provide new comment. + +7.push an existing repository from the command line + + git remote add origin git@github.com:fergusj/LearnGit.git + git push -u origin master + + 从现在起,只要本地作了提交,就可以通过命令: + $ git push origin master + + 克隆别人git + git clone git@github.com:michaelliao/gitskills.git + +8.HEAD确定当前分支,master指向最新的提交 +每次只对HEAD指向的指针dev做操作(修改),可以两个指针合并————平行空间相遇了。 + +9.Git鼓励大量使用分支: + + 查看分支:git branch + + 创建分支:git branch name + + 切换分支:git checkout name + + 创建+切换分支:git checkout -b name + + 合并某分支到当前分支:git merge name + + 删除分支:git branch -d name + +10. $ git diff readme.txt + + +11. 参数的git log也可以看到分支的合并情况: + +$ git log --graph --pretty=oneline --abbrev-commit + + +12.准备合并dev分支,请注意--no-ff参数,表示禁用“Fast forward”: +$ git merge --no-ff -m "merge with no-ff" dev +因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 +合并后,我们用git log看看分支历史: +$ git log --graph --pretty=oneline --abbrev-commit + +13.在实际开发中,我们应该按照几个基本原则进行分支管理: +首先,master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活; +那在哪干活呢? + +干活都在dev分支上,也就是说,dev分支是不稳定的,到某个时候,比如1.0版本发布时,再把dev分支合并到master上,在master分支发布1.0版本; +你和你的小伙伴们每个人都在dev分支上干活,每个人都有自己的分支,时不时地往dev分支上合并就可以了。 +所以,团队合作的分支看起来就像这样: + +14.stash临时解决主线上bug ,暂存我当前工作分支,在主线上新建issue-101来解决,后恢复现场 + +15.Feature分支 软件开发中,总有无穷无尽的新的功能要$ git branch -d feature-vulcan + +error: The branch 'feature-vulcan' is not fully merged. +If you are sure you want to delete it, run 'git branch -D feature-vulcan'. +销毁失败。Git友情提醒,feature-vulcan分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用命令git branch -D feature-vulcan不断添加进来。 + + +16.并不是一定要把本地分支往远程推送,那么,哪些分支需要推送,哪些不需要呢? + +master分支是主分支,因此要时刻与远程同步; + +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + + + +17.origin 远程仓库的默认名称 +master 本地分支 和远程 分支 + + + + +18. +他用这个命令创建本地dev分支: + +$ git checkout -b dev origin/dev + + + +19. +多人协作的工作模式通常是这样: + +首先,可以试图用git push origin branch-name推送自己的修改; + +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + +如果合并有冲突,则解决冲突,并在本地提交; + +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单 + +20.git pull 相当于更新本地的分支和github中的分支文件校准 +$ git push origin dev 相当于 推送本地分支 到github中 +Everything up-to-date + +21.标签也是版本库的一个快照。 + + + +22. git tag v1.0 当前处建立标签 + git tag v0.1 abc001 在git log 信息commit id的地方 + git tag 查询所有标签 + 默认的是按照字母排序 + git show v0.1 显示详细信息 + git tag -d v0.1 删除 + git push origin tagname 默认标签是本地的,用这个命令 推送到远程 + git push origin --tags 一次性推送所有tag + +删除已经push到origin中标签 +git tag -d v0.9 +git push origin :refs/tags/v0.9 + + +命令git push origin tagname可以推送一个本地标签; + +命令git push origin --tags可以推送全部未推送过的本地标签; + +命令git tag -d tagname可以删除一个本地标签; + +命令git push origin :refs/tags/tagname可以删除一个远程标签。 + + + + + \ No newline at end of file diff --git a/learngit/learngit.txt b/learngit/learngit.txt new file mode 100644 index 0000000000..b2fddadcf3 --- /dev/null +++ b/learngit/learngit.txt @@ -0,0 +1,3 @@ +thx, miu + +i will learn git \ No newline at end of file diff --git a/learngit/learngit140830.txt b/learngit/learngit140830.txt new file mode 100644 index 0000000000..d1843df52b --- /dev/null +++ b/learngit/learngit140830.txt @@ -0,0 +1,2 @@ +Thank you, Mr liao. +Your blog helped me a lot, I have already followed your sina weibo. diff --git a/learngit/learngit20150128.txt b/learngit/learngit20150128.txt new file mode 100644 index 0000000000..09bb273331 --- /dev/null +++ b/learngit/learngit20150128.txt @@ -0,0 +1 @@ +learn git form http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137628548491051ccfaef0ccb470894c858999603fedf000 \ No newline at end of file diff --git a/learngit/learngitbyffh.txt b/learngit/learngitbyffh.txt new file mode 100644 index 0000000000..e5b67eb2bc --- /dev/null +++ b/learngit/learngitbyffh.txt @@ -0,0 +1,3 @@ +Hello, liao: + +I am very happy to learn git. diff --git a/learngit/lecion.md b/learngit/lecion.md new file mode 100644 index 0000000000..46e4cc3877 --- /dev/null +++ b/learngit/lecion.md @@ -0,0 +1,117 @@ +##安装好git后,第一步配置: + git config --global user.name = "lecion" + git config --global user.email = "ylc931116@gmail.com" + +#初始化一个Repository + mkdir rep + cd rep + git init + +#add,commit + git add *** + git commit -m "***" + +#log + git log --pretty=oneline + git log --graph --pretty=online --abbrev-commit + git reflog + +#回到历史版本 + git reset --hard HEAD^ //HEAD表示当前版本,HEAD^ 上一个版本 HEAD^^ 上两个版本 HEAD~100 前100个版本 + +#diff 查看差异 + git diff *** + +#工作区(Working Directory) +>电脑里能看到的目录 (比如创建的learngit文件夹就是一个`工作区`) +#版本库(Repository) +>工作区有一个隐藏目录`.git`,这个不算工作区,而是Git版本库。Git的版本库里存了很多东西,最重要的称为`stage`的`暂存区`。git add 后的内容就是放在暂存区,直到被commit + +#撤销修改 + git checkout -- *** //把***在工作区的修改全部撤销 +* 没有git add,则恢复到和版本库一模一样 +* 如果git add,则恢复到缓存区的状态 + +#撤销缓存区(unstage) + git reset HEAD *** //把***的修改从缓存区移除 + +#删除文件 + rm test.txt + git rm test.txt + git commit -m "del test.txt" +>如果删错了,用git checkout -- test.txt 即可将版本库的test.txt恢复到工作区,无论是删除或是修改都可以采用此操作 + +#远程仓库 +* 使用Git,创建SSH Key + + ssh-keygen -t rsa -C "ylc931116@gmail.com" +* 登陆Github, 打开Account Settings, "SSH Keys"页面,填入 id_rsa.pub里的内容 +* Github上创建Repository `learngit` +* 将本地现有仓库和git关联 + + git remote add origin git@github.com:lecion/learngit.git + git push -u origin master + >因为是第一次提交,需要用`-u`,不但把本地master分支内容推送到远程新的master分支,还把本地的master分支和远程master分支关联起来,以后提交就可简化命令 +* 如果以后本地做了修改,就可以通过以下命令提交 + + git push orgin master + +#最好的方式 +>在远程建立一个Repository后,从远程clone + + git clone git@github.com:lecion/gitskills.git +#创建新分支 + git checkout -b dev +>`-b`表示创建并切换 + + git branch dev +>此种方式也可以 + +#查看分支 + git branch +>会列出所有分支,在当前分支前以`*`标注 + +#切换分支 + git checkout master +#合并分支 + git merge dev +#删除分支 + git branch -d dev + git branch -D dev +>`-D`强制删除没有合并的分支 + +#修复Bug + git stash +>暂存当前工作区,处理完bug后,回到该分支 + + git stash list +>查看暂存列表 + + git stash pop +>弹出最近的stash + + git stash apply + git stash drop + git stash apply@{0} + +#查看远程库 + git remote -v +>`-v`显示详细信息 + +#推送分支 + git push origin master + git push origin dev +* master分支是主分支,因此要时刻与远程同步; +* dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同 步; +* bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每 周到底修复了几个bug; +* feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + +#使用标签 + git tag v1.0 + git tag -a v0.9 -m "version 0.9 released" 234234 + git show v0.1 + git tag -d v1.0 + git push origin v1.0 + git push origin --tag + git push origin:refs/tags/v1.0 + diff --git a/learngit/leirenbaobao_UTF8.txt b/learngit/leirenbaobao_UTF8.txt new file mode 100644 index 0000000000..56c6560065 --- /dev/null +++ b/learngit/leirenbaobao_UTF8.txt @@ -0,0 +1,73 @@ +顶一下廖前辈 + +git init +git add xxx.txt +git commit xxx.txt + +git status +git diff + +git log +git log --pretty=oneline +HEAD表示当前版本, HEAD^上一个版本, HEAD^^ 上上版本 HEAD~100 +git reset +git reset --hard HEAD^ +git reset --hard 3628164(版本号) +git reflog + +工作区--add-》暂存区--commit-》master + +git记录的是对文件的修改 + +git checkout -- xxx.txt +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +git reset HEAD file + +git rm xxx.txt + +================== + +SSH加密 +ssh-keygen -t rsa -C "youremail@example.com" + +git remote add origin git@github.com:leirenbaobao/learngit.git +git push -u origin master +git push origin master + +git clone git@github.com:leirenbaobao/gitskills.git + +查看分支:git branch +创建分支:git branch +切换分支:git checkout +创建+切换分支:git checkout -b +合并某分支到当前分支:git merge +删除分支:git branch -d + +冲突修改 + +git merge --no-ff -m "merge with no-ff" ctrlz +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + +git stash +git stash list +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除;另一种方式是用git stash pop,恢复的同时把stash内容也删了 +git stash apply stash@{0} + + +git branch -D ctrlz在未完成合并的情况下 + +git remote/git remote -v + +git push origin master/git push origin ctrlz + +git tag /git tag v1.0 6224937/git tag + +命令git push origin 可以推送一个本地标签; +命令git push origin --tags可以推送全部未推送过的本地标签; +命令git tag -d 可以删除一个本地标签; +命令git push origin :refs/tags/可以删除一个远程标签。 + + diff --git a/learngit/leix101.txt b/learngit/leix101.txt new file mode 100644 index 0000000000..d2fd9646a3 --- /dev/null +++ b/learngit/leix101.txt @@ -0,0 +1 @@ +try pull request and thank you! \ No newline at end of file diff --git a/learngit/lgt945.txt b/learngit/lgt945.txt new file mode 100644 index 0000000000..9e9a73d6ed --- /dev/null +++ b/learngit/lgt945.txt @@ -0,0 +1,5 @@ +hi,michaelliao,thanks for your help about git. +初学git,发现的确是多人协作的好工具,刚开始觉得一个人学习不需要使用版本控制,但是发现其实早早的养成一个良好的学习习惯是好的开始,决定所有的过程都通过git记录下来。 +感谢Michael回复,开始以为只是没有merge我的文件,刚在邮箱里看到Michael的贴心回复,原来是我的文件没有用utf-8编码,这次再重新编码上传。。。 +anyway thanks +lgt945 \ No newline at end of file diff --git a/learngit/li-xinyang_note.md b/learngit/li-xinyang_note.md new file mode 100644 index 0000000000..1640e69945 --- /dev/null +++ b/learngit/li-xinyang_note.md @@ -0,0 +1,226 @@ +--- +BookTitle: Git-Tutorial +Author:lv +URL: http://lvwzhen.gitbooks.io/git-tutorial/ +--- + +# Git-Tutorial + +Git 为分布式版本控制系统(类似的有 Mercurial 和 Bazaar),它用于纪录文件修改详情。其他版本控制系统有 CVS(Concurrent Versions System)和 SVN (Apache Subversion) 均为集中式版本控制系统。集中式版本控制系统将版本库存放于中央服务器,需要联网且每次修改与提交均需要与服务器交换信息效率很低。分布式则使每一个使用者都拥有一个版本库(无中央服务器),这提高了效率和安全性。除此外 Git 还提供强大的分支管理。 + +**创建版本库** + +`$ git init` 将当前目录建为管理仓库。`.git` 文件来跟踪版本库。版本控制只可跟踪文本文件的改动,但无法追踪二进制变化(可知文件大小改变)。不同语言尽量使用统一编码 UTF-8 来支持全平台。 + +**文件入仓** + +首先将文件添加至仓库 `$ git add filename.txt` 然后将文件提交 `$ git commit -m "message"` (`-m` 为本次提交说明)。`commit` 可一次提交多个文件,所以可多次 `add` 不同文件,例如下面的例子。 + +``` +$ git add file1.txt +$ git add file2.txt +$ git add file3.txt +$ git commit -m "add 3 files" +``` + +**修改文本** + +`git status` 输出仓库当前状态。`git diff` 显示修改内容。 + +**版本回退** + +`git log` 查看历史纪录,其可用 `--pretty=oneline` 修改显示方式。16进制数组为版本号(Commit ID)和 SVN 不同,Git 版本号为 SHA1 计算所得(用自动递加会造成版本号冲突)。Git 使用 `HEAD` 表示当前版本,上一个版本为 `HEAD^`,再上一个为 `HEAD^^`,之后的为 `HEAD~100`(以100为例)。下面的代码返回特定版本: + +``` +$ git reset --hard HEAD^ +``` + +返回特点版本后,与其之后的所有提交均不会显示。只能使用版本号来进行之后版本的恢复操作,如下: + +``` +$ git reset --hard 3628164 +``` + +Git 内部使用 `HEAD` 指针来选当前版本。且 Git 提供 `$ git reflog` 记录每一次的命令。 + +**工作区和暂存区** + +工作区(Working Directory),版本库(Repository)中有暂存区(stage 或 index)还有第一个分支 master 以及指向它的指针 HEAD。将文件添加到版本库里分两步执行,第一步,将文件添加至暂存区,第二步,将暂存区文件提交至当前分支。既每次修改不添加暂存区将不会被添加至版本库。 + +**管理修改** + +Git 跟踪并管理*修改*,并非文件。 + +**撤销修改** + +`$ git checkout -- readme.md` 撤销全部 `readme.md` 在工作区的修改。这又分两种情况,第一种,文件并未存放至暂存区,撤销即返回和版本库相同状态。第二种,撤销返回至添加到暂存区时的状态。`--` 在此处极为重要,它在此区分撤销与创建新分支。用下面的代码将暂存区的文件回归至工作区: + +``` +$ git reset HEAD readme.md +# 放弃工作区修改 +$ git checkout -- readme.md +``` + +若修改版本已从暂存区提交至版本库,只可用版本回退的方法进行撤销,如若推送至远程库则无法撤销。文件只可恢复至当前版本库的最新版本,最近提交后的修改将丢失。 + +**删除文件** + +Git 中删除也属于修改操作。删除后的两种情况,第一种为确认删除用 `$ git rm test.txt` 将文件从工作区删除并将删除动作添加至暂存区。第二种为误删,可用 `$ git checkout -- test.txt` 恢复删除文件。 + +**远程仓库** + +GitHub 提供 Git 仓库托管,本地 Git 仓库与 GitHub 仓库间的传输通过 SSH 加密。第一步创建 SSH Key。如在用户目录下无 `.ssh` 目录,使用下面的代码创建即可: + +``` +$ ssh-keygen -t rsa -C "youremail@example.com" +``` + +在文件夹内,`id_rsa` 为私钥(Private Key),`id_rsa.pub` 为公钥(Public Key)。第二步,在 GitHub 添加 SSH Key,只需将公钥中内容粘贴至 Key 文本框即可。需要添加 SSH Key 的原因是确认身份,如有若干电脑仅需把每台设备的公钥添加即可。 + +**添加远程库** + +此时的 GitHub 仓库即可当备份也可支持多人协作。添加远程库,首先需在 GitHub 新建新库,创建后可从此仓库克隆新仓库也可使之与本地仓库相关联。关联本地仓库与远程仓库的方法: + +``` +$ git remote add origin git@github.com:username/repositoryname.git + +$ git push -u origin master +``` + +由于远程仓库为空,使用 `-u` 可推送并关联本地 master 与远程 master。在此之后的远程提交均可用 `$ git push origin master` 来完成。 + +**克隆远程库** + +`git clone` 在当前位置克隆一个本地库。当多人协作开发时,只需各自从远程服务器克隆即可。Git 支持多种协议,默认为 `git://`(速度最快)使用 SSH,但也可使用 https(速度慢且每次需要输入口令,适用于仅开放 https 端口的情况) 等其他协议。 + +**分支管理** + +在 Git 中分支的创建、切换以及删除都可以快速完成(无文件数量无关,仅为指针改变)。每一次提交 Git 都会将其串联成时间线,主线称之为*主分支*即 master 分支而 HEAD 指向的为当前分支。使用 `$ git checkout -b branchname` 创建新分支,`-b` 表示创建并切换,等同于下面的代码: + +``` +# 创建分支 +$ git branch dev +# 切换分支 +$ git checkout dev +``` + +`git branch` 用于查看当前分支,当前分支用 `*`表示。创建分支后即可在其中进行操作。操作完成后即可切换分支 `$ git checkout master`, `$ git merge dev` 合并指定分支与当前分支(Fast-forward,直接把 master 指向 dev 分支)。合并后即可删除不必要分支 `$ git branch -d dev`,因为分支操作非常便捷与迅速,所以 Git 鼓励使用分支进行任务并在完成后合并删除分支。其效果与 master 分支上工作相同但过程更安全。 + +**解决冲突** + +发生冲突后需手动解决再提交,`git status` 可以显示冲突文件。Git 用 `<<<<<<<`,`=======`,`>>>>>>>` 标记不同分支。使用带参数的 `git log` 也可查看分支合并情况: + +``` +$ git log --graph --pretty=oneline --abbrev-commit +# 查看分支合并图 +$ git log --graph +``` +**分支管理策略** + +Git 在使用 Fast-forward 时因为改变指针(无合并痕迹),删除分支后会丢失分支信息。强制禁用 Fast-forward 模式,Git 会在 merge 时进行新的 commit 这样可将分支历史查看分支信息。 + +``` +$ git merge --no-ff -m "merge with no-ff" dev +# no-ff 为禁用 Fast-forward +``` + +分支策略在开发时的几项原则,首先 master 分支最为稳定仅用于发布新版本,其次开发工作全部都应该在 dev 的分支上进行。 + +**Bug分支** + +因为 Git 中分支的强大,修复 Bug 也可使用新建临时分支的方法,修复后在合并并删除临时分支。 Git 提供 `stash` 来存储当前工作现场。 + +``` +# 查看以储存的工作区 +$ git stash list +# 恢复且不删除 stash 内容 +$ git stash apply +# 恢复指定 stash 内容(以0为例) +$ git stash apply stash@{0} +# 恢复并删除 stash 内容 +$ git stash pop +``` + +**Feature分支** + +使用 `$ git branch -D branchname` 删除未被 merge 的分支。开发新功能最好新建分支。 + +**多人协作** + +Git 自动对应本地及远程 master 分支,远程仓库默认名为 origin。 + +``` +# 查看远程仓库 +$ git remote +# 远程仓库详细信息 +$ git remote -v + +# 推送分支会推送到相应分支 +$ git push origin master +$ git push origin dev +``` + +master 为主分支需时刻于远程同步,dev 为团队工作分支也学时刻同步。 + +团队克隆(clone)默认只有 master 分支,如需其他分支则必须在本地创建远程 origin 的 dev 分支。 + +``` +$ git checkout -b dev origin/dev +``` + +使用 `git pull` 抓取最新版本,解决冲突本地合并后再次推送。多人协作流程为,首先 `git push origin branch-name` 推送修改,若失败则表示远程分支比本地更新需 `git pull` 合并。如有冲突,解决冲突后本地提交再推送,如显示 "no tracking information" 则表示本地分支与远程分支未创建链接关系,使用 `git branch --set-upstream branch-name origin/branch-name` 来创建。 + +**标签管理** + +标签为版本库快照,它为指向某个 commit 的指针(分支可移动,标签不可)。 + +创建标签可用 `git tag v1.0` 创建有说明的标签可用 `git tag -a v0.1 -m "version 1.0 release"`,查看可以 `git tag` 其顺序为字母顺序排列。为特点体检打标签可用 `git tag v1.1 6224937` 后跟 commit id 即可。查看标签信息可用 `git show v1.0` 可用查看文字说明。 + +删除标签可用 `git tag -d v0.1`。推送标签至远程 `git push origin v0.1` 或 `git push origin --tags` 推送全部本地标签。删除远程标签用如下代码: + +``` +# 先删除本地标签 +$ git tag -d v0.0 +# 删除远程标签 +$ git push origin :refs/tags/v0.0 +``` + +**忽略文件** + +GitHub [提供](https://github.com/github/gitignore)忽略文件配置文件。 + +**配置别名** + +``` +$ git config --global alias.st status +# st 设置等同于 status 更多例子如下 +$ git config --global alias.br branch +$ git config --global alias.co checkout + +# 很酷 log 显示 +$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" +``` + +**Git Cheatsheet** + +[Download](https://dl.dropboxusercontent.com/u/1725146/00_InfoHosting/tower_cheatsheet_grey_EN.pdf) + + + + + + + + + + + + + + + + + + + + diff --git a/learngit/libertyBoy b/learngit/libertyBoy new file mode 100644 index 0000000000..ae207ba066 --- /dev/null +++ b/learngit/libertyBoy @@ -0,0 +1 @@ +hello,libertyBoy diff --git a/learngit/lidc.txt b/learngit/lidc.txt new file mode 100644 index 0000000000..964675ac06 --- /dev/null +++ b/learngit/lidc.txt @@ -0,0 +1 @@ +感谢廖大师让我学会了基本的git相关知识,再次感谢! diff --git a/learngit/lifelong.txt b/learngit/lifelong.txt new file mode 100644 index 0000000000..9266bb1cad --- /dev/null +++ b/learngit/lifelong.txt @@ -0,0 +1 @@ +谢谢廖老师!!!^.^ \ No newline at end of file diff --git a/learngit/lihuacan.txt b/learngit/lihuacan.txt new file mode 100644 index 0000000000..10c7833d17 --- /dev/null +++ b/learngit/lihuacan.txt @@ -0,0 +1,3 @@ +I read your blogs. +I want to try. +Thank you! \ No newline at end of file diff --git a/learngit/lijunyu.txt b/learngit/lijunyu.txt new file mode 100644 index 0000000000..16910a5f02 --- /dev/null +++ b/learngit/lijunyu.txt @@ -0,0 +1 @@ +额,真的会上瘾,感觉自己病了,病的不轻,头一次有这么强烈的主动学习的愿望,我怎么了!!!!都是你害的!!! \ No newline at end of file diff --git a/learngit/likeban.txt b/learngit/likeban.txt new file mode 100644 index 0000000000..caab7c6986 --- /dev/null +++ b/learngit/likeban.txt @@ -0,0 +1,3 @@ +Thank you so much for your work on Python and Git for me, one freshman. +Absolutely, these are best choices for me to start Python and git. +Again, thank you so sincerely! diff --git a/learngit/lintaian-github-pullrequest-test.txt b/learngit/lintaian-github-pullrequest-test.txt new file mode 100644 index 0000000000..f39ded7095 --- /dev/null +++ b/learngit/lintaian-github-pullrequest-test.txt @@ -0,0 +1 @@ +hehe,pass or not pass,I don`t care! diff --git a/learngit/linzhenan.txt b/learngit/linzhenan.txt new file mode 100644 index 0000000000..61fb7a20d8 --- /dev/null +++ b/learngit/linzhenan.txt @@ -0,0 +1,3 @@ +Git is much different from SVN and Visual Studio Online. +I believe it will be my friend when I set out for Linux from Windows. +Thank you for this useful tutorial. \ No newline at end of file diff --git a/learngit/lipsummeow.txt b/learngit/lipsummeow.txt new file mode 100644 index 0000000000..6f732c73e1 --- /dev/null +++ b/learngit/lipsummeow.txt @@ -0,0 +1,3 @@ +Thousand thanks for writting such a wonderful, short and yet to the point tutorial:) +Way better than the "Pro Git" written by ... sorry don't even remember the author's name, threw the printout into the recycle bin when i found your blog:) +Total respect in your great work! I also read the Python tutorial:) diff --git a/learngit/lir6206.txt b/learngit/lir6206.txt new file mode 100644 index 0000000000..c0bcfb9fc2 --- /dev/null +++ b/learngit/lir6206.txt @@ -0,0 +1 @@ +thank you! \ No newline at end of file diff --git a/learngit/lishuailibertine b/learngit/lishuailibertine new file mode 100644 index 0000000000..2d73f3a91e --- /dev/null +++ b/learngit/lishuailibertine @@ -0,0 +1 @@ +哎呦嘿 diff --git a/learngit/littledou_learngit.txt b/learngit/littledou_learngit.txt new file mode 100644 index 0000000000..03bbbc5107 --- /dev/null +++ b/learngit/littledou_learngit.txt @@ -0,0 +1,118 @@ +# git_use +创建版本库-- +$ mkdir learngit +$ cd learngit +$ pwd +/Users/michael/learngit + + + git init--创建git仓库 + + git add readme.txt--用命令git add告诉Git,把文件添加到仓库: + + git commit -m "wrote a readme file"--用命令git commit告诉Git,把文件提交到仓库 + + git status--当前版本库状态.git status命令可以让我们时刻掌握仓库当前的状态 + + git diff readme.txt--顾名思义就是查看difference,显示的格式正是Unix通用的diff格式 + + git log--查看log日志, + + git log --pretty=oneline--日志转成一行,比较醒目 + + git reset --hard HEAD^--回退一个版本 + + git reset --hard 3628164--回退到版本3628164 + + cat readme.txt--看看readme.txt的内容 + + git reflog--Git提供了一个命令git reflog用来记录你的每一次命令 + + + 第一步是用git add把文件添加进去,实际上就是把文件修改添加到暂存区; + + 第二步是用git commit提交更改,实际上就是把暂存区的所有内容提交到当前分支。 + + git checkout -- readme.txt--把readme.txt文件在工作区的修改全部撤销,这里有两种情况: + +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; + +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 + +总之,就是让这个文件回到最近一次git commit或git add时的状态 + + git reset HEAD readme.txt--git reset命令既可以回退版本,也可以把暂存区的修改回退到工作区 + + 要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; + + 关联后,使用命令git push -u origin master第一次推送master分支的所有内容;此后,每次本地提交后, + 只要有必要,就可以使用命令git push origin master推送最新修改; + + git clone git@github.com:littledou/git_use.git--克隆版本库 + + git branch --查看分支 + + git branch dev --创建分支dev + + git checkout dev--切换到分支dev + + git checkout -b dev--创建dev分支并切换到dev + + git merge dev --合并dev分支到当前分支 + + git branch -d dev-- 删除分支dev + + +# 解决冲突 + + 分支dev修改了README.md,切换到主分支也去修改README.md,这样冲突无法直接merge,先 git merge dev,然后查看文件详情中出现的《《《HEAD,调整修改之后在master上提交 + + git merge --no-ff -m "merge with no-ff" dev--强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息 + +# Bug解决 + + 当前在dev分支需要去master解决1bug + + git stash 把当前工作现场“储藏”起来,等以后恢复现场后继续工作:切到master chackout一个issue分支,解决bug合并到master删除issue切到dev + + git stash list--查看当前保存的工作区 + + git stash apply--恢复保存的工作区 + + git stash drop-- 删除stash + + git stash pop--恢复并删除 + + +#强制删除某未合并的功能分支 + + git branch -D feature + +# 多人协作 + + git remote--查看远程库的信息 + + git remote -v --查看更详细的信息 + + +#标签管理 + + git tag v1.0--创建v1.0表签 + + git tag --查看标签 + + git tag v1.0 6224234--对某次提交打标签 + + git show v1.0--标签信息 + + git tag -d v1.0--删除标签 + + git push origin --tags--将全部未提交的标签提交到远程 + + 已提交的标签删除 + + git tag -d v1.0->git push origin :refs/tags/v1.0 + + + + \ No newline at end of file diff --git a/learngit/liuiuii.txt b/learngit/liuiuii.txt new file mode 100644 index 0000000000..5db0025125 --- /dev/null +++ b/learngit/liuiuii.txt @@ -0,0 +1 @@ +hello ,thank you! \ No newline at end of file diff --git a/learngit/liuluheng_learngit.txt b/learngit/liuluheng_learngit.txt new file mode 100644 index 0000000000..8a03523b06 --- /dev/null +++ b/learngit/liuluheng_learngit.txt @@ -0,0 +1,2 @@ +git has many things to learn, +not so easy to grasp....:(..:). diff --git a/learngit/liuxiaokun b/learngit/liuxiaokun new file mode 100644 index 0000000000..dcb64ddf92 --- /dev/null +++ b/learngit/liuxiaokun @@ -0,0 +1 @@ +test how to send a pull request! diff --git a/learngit/liuxu0315.txt b/learngit/liuxu0315.txt new file mode 100644 index 0000000000..caf4829607 --- /dev/null +++ b/learngit/liuxu0315.txt @@ -0,0 +1,199 @@ +廖雪峰的官方网站: + www.liaoxuefeng.com + +Git教程总结: +--------------------------------------------------------------------------------------------------------- +git-----| + |----安装git----| + | |--Ubuntu--| + | | 安装git: + | | $ sudo apt-get install git + | | 配置git: + | | $ git config --global user.name "Your Name" + | | $ git config --global user.email "email@example.com" + | + | + |--创建版本库---| + | |--创建本地git工作目录--| + | | $ mkdir git + | | $ cd git + | | $ git init + | | + | |--第一次提交到本地git库--| + | | $ vim liuxu0315.txt + | | $ git add liuxu0315.txt + | | $ git commit -m "add liuxu0315.txt" + | + | + |--时光机穿梭---| + | |-------| + | | 查看当前状态: + | | $ git status + | | 查看difference: + | | $ git diff + | | + | |--版本退回--| + | |-------查看提交历史记录: + | | $ git log + | | $ git log --pretty=oneline + | |-------退回上一个版本: + | | $ git reset --hard HEAD^ + | | 退回上上一个版本: + | | $ git reset --hard HEAD^^ + | | 退回往上100个版本: + | | $ git reset --hard HEAD~100 + | |-------从上一版本回到当前版本: + | | 查看历史命令: + | | $ git relog + | | (得到当前版本commid id:3628164) + | | 返回到当前版本: + | | $ git reset --hard 3628164 + | | + | |--撤销修改--| + | |-------修改文件: + | | $ vim liuxu0315.txt + | | (噢,改错了,要返回修改前) + | | 撤销修改: + | | $ git checkout -- liuxu0315.txt + | |-------再次修改: + | | $ vim liuxu0315.txt + | | $ git add liuxu0315.txt + | | (完蛋了,又修改错了) + | | 取消此次add: + | | $ git reset HEAD liuxu0315.txt + | | 撤销修改: + | | $ git checkout -- liuxu0315.txt + | | + | |--删除文件--| + | | $ rm liuxu0315.txt + | | $ git rm liuxu0315.txt + | | $ git commit -m "rm liuxu0315.txt" + | + | + |---远程仓库----| + | |--创建设置SSH Key--| + | | 1.创建SSH Key: + | | $ ssh-keygen -t rsa -C "youremail@example.com" + | | 2.将~/.ssh/id_rsa.pub复制到github的"个人设置-->SSH Keys"处。 + | | + | |--添加远程库--| + | | 1.在github中先添加好一个仓库。 + | | (得到一个如:git@github.com:liuxu0315/helloworld.git 这样地址) + | | (liuxu0315则是你的github ID) + | | 2.在本地仓库下运行: + | | $ git remote add origin git@github.com:liuxu0315/helloworld.git + | | 此时可以推送到远程github仓库了: + | | $ git push -u origin master + | | (参数 -u 是将本地master分支和远程master分支关联起来) + | | + | |--克隆远程仓库--| + | | $ git clone git@github.com:michaelliao/learngit.git + | + | + |---远程分支----| + | |--创建与合并分支--| + | |-------创建并跳转到dev分支: + | | $ git checkout -b dev + | | (git checkout为跳转到分支,-b为新建分支) + | |-------创建dev分支: + | | $ git branch dev + | | 跳转到dev分支: + | | $ git checkout dev + | |-------查看分支: + | | $ git branch + | | + | |-------然后在dev分支上工作: + | | $ vim dev.txt + | | $ git add dev.txt + | | $ git commit -m "add dev.txt" + | |-------回到master合并dev分支: + | | $ git checkout master + | | $ git merge dev + | |-------删除dev分支: + | | $ git branch -d dev + | | + | |--解决冲突--| + | | (当在dev和master同时修改dev.txt文件后,) + | | (在master中合并dev分支是会冲突) + | | (此时需要编辑一下dev.txt解决掉冲突,) + | | (然后再add , commit提交) + | | + | |--工作区暂存--| + | | (用于:需要跳转到其他分支,) + | | ( 又不想commit当前分支,) + | | ( 也不想放弃当前修改时) + | | + | |-------保存当前工作现场: + | | $ git stash + | | (跳转到其他分支工作后再回来此分支) + | |-------恢复工作现场: + | | 1.查看以保存的stash内容: + | | $ git stash list + | | (可以看到0个或多个stash@{n},n=1,2,3,4...) + | | 2.恢复工作现场: + | | $ git stash apply + | | (或者) + | | $ git stash apply stash@{0} + | | 3.删除stash内容: + | | $ git stash drop + | |---------------直接恢复并删除stash内容: + | | $ git stash pop + | + | + |---标签管理----| + | |--创建标签--| + | |-------快速创建标签:(例:$ git tag ) + | | $ git tag v1.0 + | | 查看标签: + | | $ git tag + | | 给以前的commit id为6224937打标签: + | | $ git tag v0.9 6224937 + | | 查看标签详细信息: + | | $ git show v0.9 + | |-------创建带说明的标签(commit为3628164): + | | $ git tag -a v0.1 -m "version 1.0" 3628164 + | | 创建带GPG密钥的标签(确定本地已经配置和GPG KEY): + | | $ git tag -s v0.2 -m "signed version 0.2 released" fec145a + | | + | |--操作标签--| + | |-------删除本地某个标签: + | | $ git tag -d v0.1 + | | 推送某个标签到远程仓库: + | | $ git push origin v1.0 + | | 一次全部推送未推送的本地标签: + | | $ git push origin --tags + | |-------删除远程仓库标签: + | | $ git tag -d v0.9 + | | $ git push origin :refs/tags/v0.9 + | + | + |---自定义Git---| + | |--忽略特殊文件--| + | | 1.将忽略的文件写入.gitignore中 + | | $ vim .gitignore + | | (如:) + | | (dev.txt) + | | (*.class) + | | (temp/) + | | 2.提交.gitignore到git仓库 + | | $ git add .gitignore + | | $ git commit -m "add .gitigonre" + | | + | |--配置别名--| + | | $ git config --global alias.st status + | | $ git st + | | $ git config --global alias.co checkout + | | $ git config --global alias.ci commit + | | $ git config --global alias.br branch + | | $ git config --global alias.unstage 'reset HEAD' + | | $ git config --global alias.last 'log -l' + | | $ git config --llobal alias.lg "log --color --graph + | | --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset + | | %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" + | | $ git lg + | | + | | (以上配置放在 .git/config 中,) + | | (个人配置文件在 ~/.gitconfig 中) + + + diff --git a/learngit/liye71023326.txt b/learngit/liye71023326.txt new file mode 100644 index 0000000000..6b71494ed2 --- /dev/null +++ b/learngit/liye71023326.txt @@ -0,0 +1 @@ +今天一天按照教程实际操作了各条命令,收益很大,非常感谢。 diff --git a/learngit/liyingzh.txt b/learngit/liyingzh.txt new file mode 100644 index 0000000000..91f78fd01c --- /dev/null +++ b/learngit/liyingzh.txt @@ -0,0 +1,47 @@ +1 初始化一个Git仓库,使用git init命令。 + +2 添加文件到Git仓库,分两步: + 第一步,使用命令git add ,注意,可反复多次使用,添加多个文件; + 第二步,使用命令git commit,完成。 + +3 要随时掌握工作区的状态,使用git status命令。 + +4 如果git status告诉你有文件被修改过,用git diff可以查看修改内容。 + +5 HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 + +6 穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 + +7 要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。 + +8 Git跟踪修改,每次修改,git add再git commit. 如果不add到暂存区,那就不会加入到commit中。 + +9 撤销修改 + 场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 + 场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 + +10 + 查看分支:git branch + 创建分支:git branch + 切换分支:git checkout + 创建+切换分支:git checkout -b + 合并某分支到当前分支:git merge + 删除分支:git branch -d + 用git log --graph命令可以看到分支合并图。 + 要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 +11 + 查看远程库信息,使用git remote -v; + 本地新建的分支如果不推送到远程,对其他人就是不可见的; + 从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + 在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + 建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + 从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 +12 + 命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; + git tag -a -m "blablabla..."可以指定标签信息; + 命令git tag可以查看所有标签。 + 命令git push origin 可以推送一个本地标签; + 命令git push origin --tags可以推送全部未推送过的本地标签; + 命令git tag -d 可以删除一个本地标签; + 命令git push origin :refs/tags/可以删除一个远程标签。 +13 Fork A Repo:https://help.github.com/articles/fork-a-repo/ diff --git a/learngit/lnddStrong.txt b/learngit/lnddStrong.txt new file mode 100644 index 0000000000..90a685ebe5 --- /dev/null +++ b/learngit/lnddStrong.txt @@ -0,0 +1 @@ +thank you very much! \ No newline at end of file diff --git a/learngit/loveuqian.txt b/learngit/loveuqian.txt new file mode 100644 index 0000000000..47c788b03b --- /dev/null +++ b/learngit/loveuqian.txt @@ -0,0 +1 @@ +thanks for your git course diff --git a/learngit/lucien.txt b/learngit/lucien.txt new file mode 100644 index 0000000000..9f4c7831f2 --- /dev/null +++ b/learngit/lucien.txt @@ -0,0 +1 @@ +Thx for your course! diff --git a/learngit/luckyflower.txt b/learngit/luckyflower.txt new file mode 100644 index 0000000000..00aa7fc184 --- /dev/null +++ b/learngit/luckyflower.txt @@ -0,0 +1,44 @@ +git init 初始化一个Git仓库 +git add 文件添加到仓库(实际上就是把文件修改添加到暂存区;) +git commit -m "xx" 把文件提交到仓库(实际上就是把暂存区的所有内容提交到当前分支) +git status 仓库当前的状态 +git diff 查看修改内容 +git log 查看从最近到最远的提交日志(嫌输出信息太多,可以加上 ?--pretty=oneline 参数) +HEAD 指当前版本(上一个版本就是HEAD^,上上一个版本就是HEAD^^,100个版本可写成HEAD~100) +git reset --hard commit_id 在版本的历史之间穿梭 +git reflog 查看命令历史,可重返未来的版本 +git diff HEAD -- 查看工作区和版本库里面最新版本的区别 +git checkout -- file 丢弃工作区的修改(若未git add到暂存区,直接丢弃工作区的修改) +git reset HEAD file 把暂存区的修改撤销掉,重新放回工作区(已经git add到了暂存区,先撤销放回工作区,再执行丢弃工作区修改的命令) +git rm 删除一个文件 +git remote add origin git@server-name:path/repo-name.git 将本地仓库与远程库关联起来 +git clone git@server-name:path/repo-name.git 将远程库克隆到本地 +git push -u origin master 第一次推送master分支的所有内容; +git push origin master 把当前分支master推送到远程 +git branch 查看分支 +git branch 创建分支 +git checkout 切换分支 +git checkout -b 创建+切换分支 +git merge 合并某分支到当前分支(启用Fast forward模式,删除分支后,会丢掉分支信息) +git merge --no-ff 合并某分支到当前分支(启用普通模式,合并后的历史有分支,能看出来曾经做过合并) +git branch -d 删除分支 +git log --graph 查看分支合并图 +git stash 当前工作现场“储藏”起来,等以后恢复现场后继续工作 +git stash list 查看被‘储藏’的工作现场 +git stash apply 恢复被‘储藏’的工作现场 +git stash drop 删除被‘储藏’的工作现场 +git stash pop 恢复+删除被‘储藏’的工作现场 +git branch -D 强行删除丢弃一个没有被合并过的分支 +git remote 查看远程库的信息 +git remote -v 显示远程库更详细的信息 +git push origin branch-name 推送分支,就是把该分支上的所有本地提交推送到远程库。 +git checkout -b branch-name origin/branch-name 在本地创建和远程分支对应的分支 +git branch --set-upstream branch-name origin/branch-name 指定本地分支与远程分支的链接(链接关系没有创建会提示“no tracking information”) +git pull 把最新的提交从远程库origin抓下来 +git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; +git tag 查看所有标签 +git show 查看标签信息 +git push origin 推送一个本地标签 +git push origin --tags 推送全部未推送过的本地标签 +git tag -d 删除一个本地标签 +git push origin :refs/tags/ 删除一个远程标签 \ No newline at end of file diff --git a/learngit/lwzhang.txt b/learngit/lwzhang.txt new file mode 100644 index 0000000000..88a66e2a5d --- /dev/null +++ b/learngit/lwzhang.txt @@ -0,0 +1 @@ +非常棒的教程!非常感谢! \ No newline at end of file diff --git a/learngit/lynntalk.txt b/learngit/lynntalk.txt new file mode 100644 index 0000000000..31ce1b7053 --- /dev/null +++ b/learngit/lynntalk.txt @@ -0,0 +1,3 @@ +thanks for your article. +i have learnt more about git. +your website is briliant. diff --git a/learngit/lzm.test b/learngit/lzm.test new file mode 100644 index 0000000000..021a8aa680 --- /dev/null +++ b/learngit/lzm.test @@ -0,0 +1,2 @@ +hello +push test diff --git a/learngit/m-yo.txt b/learngit/m-yo.txt new file mode 100644 index 0000000000..2d3189098a --- /dev/null +++ b/learngit/m-yo.txt @@ -0,0 +1,10 @@ +This is my first time to learn git. +Thank you so much for your blog course. +It is very easy to understand for beginners like me. +A new world is open to me now after taking this course. +Thank you!! +誠にありがとうございました! + +Best Regards, +yuman + diff --git a/learngit/manythanks.txt b/learngit/manythanks.txt new file mode 100644 index 0000000000..384283dfd1 --- /dev/null +++ b/learngit/manythanks.txt @@ -0,0 +1,7 @@ +many thanks for your effort to make git easy for us to learn it well . +Actually, I used to have some konwledge about git , as it's really a powerfull tool for porgrammer, and make up my mind to leran it well. +but ,I did not find a suitable tutrial... so I qiut ..finaly..OOOO + +your tutrial benefits me a lot .. + +thanks ! diff --git a/learngit/mark442.txt b/learngit/mark442.txt new file mode 100644 index 0000000000..57cf9e8e95 --- /dev/null +++ b/learngit/mark442.txt @@ -0,0 +1 @@ +git教程非常详细,对于初学者非常有益,感谢分享. \ No newline at end of file diff --git a/learngit/markdown_log.md b/learngit/markdown_log.md new file mode 100644 index 0000000000..78257733e6 --- /dev/null +++ b/learngit/markdown_log.md @@ -0,0 +1,163 @@ +t是什么? + +- Git是`分布式版本控制系统`。而集中式的版本控制系统不但速度慢,而且必须联网才能使用。 +- 2008年,GitHub网站上线(程序员社区网站,这网站上可以托管自己的网站库,基于Git完成的) + +> ###Git的作用 + +- 备份文件 +- 记录历史 +- 回到过去 +- 多端共享 +- 团队协作 + +> ###Git的诞生 + +Linus创建了Linux(1991年),由于很多人提交代码,都是最后都是通过手工方式合并的(1991年-2002年)。最后很多人都有意见,于是Linus选择了(2002年)一个商业的版本控制系统BitKeeper,但是开发Samba的Andrew`试图破解`BitKeeper的协议(2005年4月),于是BitMover公司怒了,要收回Linux社区的免费使用权。于是Linus花了两周时间自己用C写了一个`分布式版本控制系统`,这就是Git!(2005年4月初发布) + +> ###分布式和集中式的区别 + +- 集中式版本控制系统最大的毛病就是必须联网才能工作,如果`网速慢`就很悲剧、如果不联网就没有办法提交,查看记录。 +- 分布式版本控制系统根本没有“中央服务器”,每个人的电脑上都是一个完整的版本库,就不需要联网了 +- 你的同事也在他的电脑上改了文件A,这时,你们俩之间只需把各自的修改推送给对方,就可以互相看到对方的修改了。 +- 分布式版本控制系统的安全性要高很多,因为每个人电脑里都有完整的版本库,某一个人的电脑坏掉了不要紧 +- 而集中式版本控制系统的中央服务器要是出了问题,所有人都没法干活了。 +- Git极其强大的分支管理 + +在实际使用分布式版本控制系统的时候,其实很少在两人之间的电脑上推送版本库的修改,因为可能你们俩不在一个局域网内,两台电脑互相访问不了,也可能今天你的同事病了,他的电脑压根没有开机。因此,分布式版本控制系统通常也有一台充当“中央服务器”的电脑,但这个服务器的作用仅仅是用来方便“交换”大家的修改,没有它大家也一样干活,只是交换修改不方便而已。 + +> ###安装完成后(安装过程自行查阅),设置用户名和密码 + +``` +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +``` +注意`git config`命令的`--global`参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。 + +如果要查看全局参数就输入 `git config --global --list` +查看Git版本`git --version` + + +--- + + +> ###创建版本库 + +1. 进入某个目录 +2. 使用 `git init`把这个目录变成版本库,这时目录下会多出一个.git的隐藏目录,千万不要修改这个目录的东西,所有Git的记录都在里面 + +> ###把文件添加到版本库 + +1. 先修改一个文件a.php +2. 使用`git add a.php`(把这个文件添加到暂存区) +3. 使用`git commit -m '增加了xxx函数'`(把文件提交到当前分支) + +每当你觉得文件修改到一定程度的时候,就可以“保存一个快照”,这个快照在Git中被称为commit。一旦你把文件改乱了,或者误删了文件,还可以从最近的一个`commit`恢复 + +> ###状态查看 + +- `git status`查看当前状态 +- `git diff a.php` 查看没有add的a.php和已add的a.php的区别(如果文件已经add到暂存区则diff无法查看) + +> ###版本退回 + +在退回到某个commit快照版本之前,我们必须要知道那个版本的ID号 + +在Git中,用`HEAD`表示当前版本,也就是最新的提交`3628164...882e1e0`,上一个版本就是`HEAD^`,上上一个版本就是`HEAD^^`,当然往上100个版本写100个^比较容易数不过来,所以写成`HEAD~100` + +- 如果我们commit(快照、提交到当前分支)很多次文件,那么肯定记不住哪次提交修改了哪些内容,这时候就可以通过`git log`命令来查看(倒序显示,最新的修改在最前面),如果嫌输出的信息太多,我们可以使用`git log --pretty=oneline`来简洁查看,输出的一大串字符串是`commit id`也就是`版本号` +- 既然我们知道了版本号,那么如何退回到指定的版本呢?我们可以通过`git reset --hard 3628164`命令来退回到指定的版本(注意:这里的`--hard`的意思是版本号`指针`),版本号没必要写全,前几位就可以了,Git会自动去找。当然也不能只写前一两位,因为Git可能会找到多个版本号,就无法确定是哪一个了。`OK,我们现在已经可以回到过去!` +- 既然我们回到了过去,但是又后悔了,想回到原来的地方,但是,这时候使用`git log`发现,这时候已经看不到未来的版本号了,当前的版本号是最新的!那么这样就意味着,找不到未来的版本号了?找不到未来的版本号也就意味着回不去了!那么怎么办呢?Git提供了一个命令`git reflog`用来记录你的每一次命令,也就是说:你可以通过`git reflog`命令找到未来的版本号,用于回到未来! + +``` +也就是说 + +现在有3个版本 + +版本号:333 + +版本号:222 + +版本号:111 + +我现在用git reset —hard 222 退回到222版本, + +git log 后 就看不到333版本了 + +必须要用git relog才能看到222之前的333版本号 + +然后在通过git reset —hard 333 恢复到333 + +``` + + + +> ###撤销修改 + +我在文件a.php添加了一行“我的傻逼老板任然喜欢SVN”。突然发现,如果这么写本老板看见了,就完蛋啦。 + +这时候查看`git status` 说明可以用`git checkout -- a.php`来放弃工作区修改。 + + + +``` + +这里有两种情况: +一种是a.php自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是a.php已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +总之,就是让这个文件回到最近一次git commit或git add时的状态。 +``` + +如果你已经把不该说的话添加到了暂存区,那么查看`git status` 说明可以用`git reset HEAD file`可以把暂存区的修改撤销掉(unstage),重新放回工作区 + +如果已经提交了,则只能用版本退回! + + + +> ###删除文件 + + + +我现在添加一了个conf.php文件,但是写完这个文件并提交commit后,发现不需要了,就把它在工作区删掉。这时候版本库的文件和工作区的文件就不一样了(工作区多了一个conf.php文件,而版本库还没删掉),那么就要把它从版本库删掉,用:`git rm conf.php`,并且把这一次的删除,提交到版本库,这样工作区和版本库就一致了。 + +如果还没有commit之前(但是已经提交到暂存区),发现,这时候我又需要这个文件了怎么办呢?那么就要用:`git reset HEAD `(从暂存区恢复)在用`git checkout -- `(用版本库里的版本替换工作区的版本)恢复 + + + +> ###创建、合并分支 + + + +1. 创建debug分支`git branch debug`在切换到debug分支`git checkout debug` ,也可以一句话简写`git checkout -b debug`,-b参数表示创建并切换 + +2. 用`git branch`查看当前分支,命令会列出所有分支,当前分支前面会标一个*号 + +3. 修改当前分支文件,并commit + +4. 在切换到master分支:`git checkout master`,这时候,查看debug分支修改的内容,是查不到的,因为不是在当前的master分支下修改的,那么我们就要合并分支 + +5. 合并分支:`git merge debug` 注意!!!这里合并分支方式是`Fast forward`模式,但这种模式下,`删除分支后,会丢掉分支信息!`我们要禁用这`Fast forward`模式,加上`--no-ff`参数就可以用`普通模式`合并,合并后的历史有分支,能看出来曾经做过合并,而`fast forward`合并就看不出来曾经做过合并。必须要用:`git merge --no-ff -m "merge with no-ff" debug` 这样来合并分支,因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 + +6. 合并完成后,我们就可以删掉debug分支了:`git branch -d debug` + +7. 然后我们在查看分支`git branch`,debug分支果然被删除了 + +8. 用`git log --graph --pretty=oneline`分支合并图 + + + +> ###修复BUG的stash + +- 如果你正在dev分支干活,这时候接到一个紧急修复BUG的任务,但是你的dev分支工作只进行到一半,还没法提交,幸好,Git还提供了一个`git stash`功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作。 + +- 用`git stash list`命令查看储存的工作区,一是用`git stash apply`恢复,但是恢复后,stash内容并不删除,你需要用`git stash drop`来删除; 另一种方式是用`git stash pop`,恢复的同时把stash内容也删了: + + + + + + + + + + diff --git a/learngit/marvin-git-marvincreat.txt b/learngit/marvin-git-marvincreat.txt new file mode 100644 index 0000000000..67410b56f3 --- /dev/null +++ b/learngit/marvin-git-marvincreat.txt @@ -0,0 +1,3 @@ +thank you! +very easy to understand +best wishes to you and hope you write more tutorials. diff --git a/learngit/maxfong.txt b/learngit/maxfong.txt new file mode 100644 index 0000000000..ebb0000c2a --- /dev/null +++ b/learngit/maxfong.txt @@ -0,0 +1,31 @@ +ssh-keygen -t rsa -C "youremail@example.com” +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; + +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改 + +查看分支:git branch +创建分支:git branch name +切换分支:git checkout name +创建+切换分支:git checkout -b name +合并某分支到当前分支:git merge name +删除分支:git branch -d name + + + +暂存:git stash +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +$ git stash list$ git stash apply stash@{0} + +查看远程库信息,使用git remote -v; + +本地新建的分支如果不推送到远程,对其他人就是不可见的; + +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 \ No newline at end of file diff --git a/learngit/me.txt b/learngit/me.txt new file mode 100644 index 0000000000..f2aa86d258 --- /dev/null +++ b/learngit/me.txt @@ -0,0 +1 @@ +hello diff --git a/learngit/mecup.txt b/learngit/mecup.txt new file mode 100644 index 0000000000..0bc2ea4dbd --- /dev/null +++ b/learngit/mecup.txt @@ -0,0 +1,7 @@ +very good + +thank you very much for your best git lesson! + + mecup + 2015.4.10 + diff --git a/learngit/mintyminty.txt b/learngit/mintyminty.txt new file mode 100644 index 0000000000..9c42f7b4b2 --- /dev/null +++ b/learngit/mintyminty.txt @@ -0,0 +1,3 @@ +just spent this afternoon playing with git, thanks Michael for the awesome tutorial! :DD + +Greetings from Canada ;-) diff --git a/learngit/mls.txt b/learngit/mls.txt new file mode 100644 index 0000000000..2706ab3827 --- /dev/null +++ b/learngit/mls.txt @@ -0,0 +1 @@ +多谢 \ No newline at end of file diff --git a/learngit/more-github-id.txt b/learngit/more-github-id.txt new file mode 100644 index 0000000000..770f77e3bb --- /dev/null +++ b/learngit/more-github-id.txt @@ -0,0 +1 @@ +this is my push. \ No newline at end of file diff --git a/learngit/mrhopelee.txt b/learngit/mrhopelee.txt new file mode 100644 index 0000000000..1960915356 --- /dev/null +++ b/learngit/mrhopelee.txt @@ -0,0 +1 @@ +I was a rookie, but I will try my best \ No newline at end of file diff --git a/learngit/muyunlei@gmail.txt b/learngit/muyunlei@gmail.txt new file mode 100644 index 0000000000..c67354c1c0 --- /dev/null +++ b/learngit/muyunlei@gmail.txt @@ -0,0 +1,2 @@ +谢谢带来这么通俗易懂的Git教程! +Thx so much! diff --git a/learngit/my-git-linxiaolong.txt b/learngit/my-git-linxiaolong.txt new file mode 100644 index 0000000000..21b405d8c2 --- /dev/null +++ b/learngit/my-git-linxiaolong.txt @@ -0,0 +1 @@ +import os diff --git a/learngit/my-github-1.txt b/learngit/my-github-1.txt new file mode 100644 index 0000000000..73b450fa47 --- /dev/null +++ b/learngit/my-github-1.txt @@ -0,0 +1,3 @@ +Mr. Liao , +Thank you very much for teaching Git. +2015-03-02 diff --git a/learngit/my-github-ZiYangLqm.txt b/learngit/my-github-ZiYangLqm.txt new file mode 100644 index 0000000000..6f573ca585 --- /dev/null +++ b/learngit/my-github-ZiYangLqm.txt @@ -0,0 +1 @@ +非常感谢! \ No newline at end of file diff --git a/learngit/my-github-id.txt b/learngit/my-github-id.txt new file mode 100644 index 0000000000..b54c66f9f1 --- /dev/null +++ b/learngit/my-github-id.txt @@ -0,0 +1 @@ +test pull diff --git a/learngit/my-github-pull-test.txt b/learngit/my-github-pull-test.txt new file mode 100644 index 0000000000..40e85cca35 --- /dev/null +++ b/learngit/my-github-pull-test.txt @@ -0,0 +1 @@ +Git very good! \ No newline at end of file diff --git a/learngit/my-github-susan.txt b/learngit/my-github-susan.txt new file mode 100644 index 0000000000..7cf3929ac9 --- /dev/null +++ b/learngit/my-github-susan.txt @@ -0,0 +1,4 @@ +读了你的这篇GitHub教程,才真正的在头脑中对GitHub有了一个清晰的概念。 +否则在以前,总是以为GitHub很神秘。 +现在只是感觉Git好伟大,linus好伟大,如你一样的程序员也好伟大。 +我也要努力! \ No newline at end of file diff --git a/learngit/my-github-wk.txt b/learngit/my-github-wk.txt new file mode 100644 index 0000000000..a1209cb690 --- /dev/null +++ b/learngit/my-github-wk.txt @@ -0,0 +1,6 @@ +thank you, a good session +赞一个,非常好的教程! +能否增加一些关于GIT挂钩的教程以及merge和rebase区别,谢谢! + +老师有没有解决乱码的好方法呢,谢谢!windows下面,不知道如何解决,谢谢! + diff --git a/learngit/my-learn-git b/learngit/my-learn-git new file mode 100644 index 0000000000..37b670186b --- /dev/null +++ b/learngit/my-learn-git @@ -0,0 +1,3 @@ +your lesson helps me a lot +thank you~ +sorry to not donate any money diff --git a/learngit/my_git.txt b/learngit/my_git.txt new file mode 100644 index 0000000000..c4c51911a4 --- /dev/null +++ b/learngit/my_git.txt @@ -0,0 +1 @@ +my first git log diff --git a/learngit/mytest.txt b/learngit/mytest.txt new file mode 100644 index 0000000000..a5cb291d11 --- /dev/null +++ b/learngit/mytest.txt @@ -0,0 +1,2 @@ +That's my first GitHut ID to pull the change. +Thank you. diff --git a/learngit/mzds.txt b/learngit/mzds.txt new file mode 100644 index 0000000000..e3e9bd8e33 --- /dev/null +++ b/learngit/mzds.txt @@ -0,0 +1 @@ +看了您的文章受益匪浅,感谢您的教程! \ No newline at end of file diff --git a/learngit/netwenk.txt b/learngit/netwenk.txt new file mode 100644 index 0000000000..1feaff8b9b --- /dev/null +++ b/learngit/netwenk.txt @@ -0,0 +1 @@ +thanks! diff --git a/learngit/netxiaosheng.txt b/learngit/netxiaosheng.txt new file mode 100644 index 0000000000..ecdc0e37be --- /dev/null +++ b/learngit/netxiaosheng.txt @@ -0,0 +1,5 @@ + Hi,Brother! + I am a junior student in NEPU + I study this course just one day + + Thank you ! \ No newline at end of file diff --git a/learngit/nickboyst-github-id.txt b/learngit/nickboyst-github-id.txt new file mode 100644 index 0000000000..9b7c4ea5dc --- /dev/null +++ b/learngit/nickboyst-github-id.txt @@ -0,0 +1,3 @@ +I am a new one for git, i am so lucky that i have read your paper. +I learned a lot and i will follow your courses. +Thank you so much ! diff --git a/learngit/niniliwei.txt b/learngit/niniliwei.txt new file mode 100644 index 0000000000..ea4963674d --- /dev/null +++ b/learngit/niniliwei.txt @@ -0,0 +1 @@ +Hello,Liao!Understand git deeper every time I come back to your tutorial,thanks. diff --git a/learngit/niniliwei_new.txt b/learngit/niniliwei_new.txt new file mode 100644 index 0000000000..76b1b7bd62 --- /dev/null +++ b/learngit/niniliwei_new.txt @@ -0,0 +1 @@ +我又回来学习了,再学一遍感觉就是不一样。 diff --git a/learngit/niyeqing.txt b/learngit/niyeqing.txt new file mode 100644 index 0000000000..dcae08c4d2 --- /dev/null +++ b/learngit/niyeqing.txt @@ -0,0 +1 @@ +作为一个纯自学者,PRO GIT虽好,但容易看晕,而且缺少实践。很感谢廖雪峰的这个教程,step by step,踏实而又不枯燥。好教程,赞一个! 前面确实是用Notepad++ UTF8打开,误选了应用于打开ANSI文件所致。 diff --git a/learngit/nobsu.txt b/learngit/nobsu.txt new file mode 100644 index 0000000000..1a0b90a813 --- /dev/null +++ b/learngit/nobsu.txt @@ -0,0 +1,2 @@ +今年大四,刚刚参加完校招,之前一直打算在github上面放一些自己的case,决定学习git,发现博主的教程,,连续三小时,我真的学会了git!!!!!!!!!!非常感谢 嗤嗤嗤 + diff --git a/learngit/note b/learngit/note new file mode 100644 index 0000000000..a753cd1ca9 --- /dev/null +++ b/learngit/note @@ -0,0 +1 @@ +谢谢你的教程哈 ! diff --git a/learngit/nsp.txt b/learngit/nsp.txt new file mode 100644 index 0000000000..b083e60a04 --- /dev/null +++ b/learngit/nsp.txt @@ -0,0 +1,3 @@ +my name is nsp, + +nsp is short for No Sucn Person:D \ No newline at end of file diff --git a/learngit/outstanding-heart.txt b/learngit/outstanding-heart.txt new file mode 100644 index 0000000000..dd4758ae32 --- /dev/null +++ b/learngit/outstanding-heart.txt @@ -0,0 +1 @@ +Thank you ! ^_^ diff --git a/learngit/oxbambooxo.txt b/learngit/oxbambooxo.txt new file mode 100644 index 0000000000..ea7e690d45 Binary files /dev/null and b/learngit/oxbambooxo.txt differ diff --git a/learngit/oxyzine b/learngit/oxyzine new file mode 100644 index 0000000000..ac0bb8aff0 --- /dev/null +++ b/learngit/oxyzine @@ -0,0 +1,3 @@ +学习git +教程首推廖雪峰 +搜狗输入法能直接打出这个名字 diff --git a/learngit/p1usJ4de.txt b/learngit/p1usJ4de.txt new file mode 100644 index 0000000000..3b066b6194 --- /dev/null +++ b/learngit/p1usJ4de.txt @@ -0,0 +1 @@ +Thank you... diff --git a/learngit/pangbo.txt b/learngit/pangbo.txt new file mode 100644 index 0000000000..12b3dda56d --- /dev/null +++ b/learngit/pangbo.txt @@ -0,0 +1 @@ +感谢廖雪峰,只用3个小时就让我学会了git,非常棒的教程! \ No newline at end of file diff --git a/learngit/pangjiawei19.txt b/learngit/pangjiawei19.txt new file mode 100644 index 0000000000..8e6fa4f3de --- /dev/null +++ b/learngit/pangjiawei19.txt @@ -0,0 +1 @@ +今天完整学习了git的教程,对这个东西有了初步认识,以后尝试把自己的东西管理到这里,继续努力 diff --git a/learngit/panpanxu.txt b/learngit/panpanxu.txt new file mode 100644 index 0000000000..df347113a1 --- /dev/null +++ b/learngit/panpanxu.txt @@ -0,0 +1 @@ +git通过设计减少网络通信和磁盘IO,所以在切换等操作时速度快。 diff --git a/learngit/paul2011.txt b/learngit/paul2011.txt new file mode 100644 index 0000000000..b12d51ceab --- /dev/null +++ b/learngit/paul2011.txt @@ -0,0 +1,3 @@ +hey,master Liao: + I just learn GIT from your wiki quckly and simplely!thanks for your share. now I start to learn Python ,so I will read your wiki for Python soon and expectantly! +may the GOD bless you! diff --git a/learngit/pclimbing.txt b/learngit/pclimbing.txt new file mode 100644 index 0000000000..72da71d192 --- /dev/null +++ b/learngit/pclimbing.txt @@ -0,0 +1,5 @@ +希望亲爱的michaelliao在心情好的时候看到这个~O(∩_∩)O +git教程对我很有帮助, + +祝你健康快乐! + diff --git a/learngit/pfjhetg.html b/learngit/pfjhetg.html new file mode 100644 index 0000000000..05ea632e93 --- /dev/null +++ b/learngit/pfjhetg.html @@ -0,0 +1,162 @@ + + + Evernote Export + + + + + + + + +
+
  1. 把当前这目录变成git可以管理的仓库
    $ git init
  2. 把文件添加到仓库
    $ git add filename
  3. git 仓库的状态
    $ git status
  4. 把文件提交到仓库
    $ git commit -m "wrote a readme file"
    +[master (root-commit) cb926e7] wrote a readme file
    + 1 file changed, 2 insertions(+)
    + create mode 100644 readme.txt
    +-m 后面是本次的提交说明
  5. 查看文件修改内容
    $ git diff readme.txt 
    +diff --git a/readme.txt b/readme.txt
    +index 46d49bf..9247db6 100644
    +--- a/readme.txt
    ++++ b/readme.txt
    +@@ -1,2 +1,2 @@
    +-Git is a version control system.
    ++Git is a distributed version control system.
    + Git is free software.
    +查看工作区和版本库里面最新版本的区别(HEAD指向当前的分支)
    $ git diff HEAD -- readme.txt 
    +diff --git a/readme.txt b/readme.txt
    +index 76d770f..a9c5755 100644
    +--- a/readme.txt
    ++++ b/readme.txt
    +@@ -1,4 +1,4 @@
    + Git is a distributed version control system.
    + Git is free software distributed under the GPL.
    + Git has a mutable index called stage.
    +-Git tracks changes.
    ++Git tracks changes of files.
  6. 查看提交历史(只有commit)
    $ git log
    只显示版本号和提交注视
    $ git log --pretty=oneline
    +3628164fb26d48395383f8f31179f24e0882e1e0 append GPL
    +ea34578d5496d7dd233c827ed32a8cd576c5ee85 add distributed
    +cb926e7ea50ad11b8f9e909c05226233bf755030 wrote a readme file
    +查看命令历史(包含reset,commit等)
    $ git reflog
  7. 在 git 中,当前版本用 HEAD 表示,上一个版本是 HEAD^ ,上上个版本是 HEAD^^,也可以用HEAD~+index,上10个版本可以写成 HEAD~10。
  8. 回到上一个版本
    $ git reset --hard HEAD^
    +根据版本号(3628164)回到此版本
    $ git reset --hard 3628164
  9. 查看工作区与版本库里面的文件区别
    $ git diff HEAD -- readme.txt 
    +diff --git a/readme.txt b/readme.txt
    +index 76d770f..a9c5755 100644
    +--- a/readme.txt
    ++++ b/readme.txt
    +@@ -1,4 +1,4 @@
    + Git is a distributed version control system.
    + Git is free software distributed under the GPL.
    + Git has a mutable index called stage.
    +-Git tracks changes.
    ++Git tracks changes of files.
  10. 把文件在工作区的修改全部撤销(git checkout -- file命令中的--很重要,没有--,就变成了“创建一个新分支”的命令)
    $ git checkout -- filename
    +如果文件修改后,还没有放到暂存区,撤销后,和版本的一样
    +如果文件已经放到暂存区,撤销户,回到暂存区的状态
  11. 把暂存区的文件撤销掉,重新放回工作区
    $ git reset HEAD readme.txt
    +请对照第8条git reset -- hard命令来进行区分
  12. 删除版本库里面的文件(包含再次 commit) +
    $ git rm test.txt
    +rm 'test.txt'
    +$ git commit -m "remove test.txt"
    +[master d17efd8] remove test.txt
    + 1 file changed, 1 deletion(-)
    + delete mode 100644 test.txt
  13. 生成 ssh key
    $ ssh-keygen -t rsa -C "youremail@example.com"
    +一路默认(不要密码)
    +/Users/js/.ssh  里面保存了生成的 key .pub 是公钥
  14. 添加远程仓库
    +首先在 git 新建一个仓库(git init),把这个仓库与本地仓库关联
    $ git remote add origin git@github.com:michaelliao/learngit.git
    +第一次把本地仓库的所有内容推送到远程库
    $ git push -u origin master
    +以后每次提交
    $ git push origin master
  15. SSH 警告(当你第一次使用Git的clone或者push命令连接GitHub时,会得到一个警告)
    The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
    +RSA key fingerprint is xx.xx.xx.xx.xx.
    +Are you sure you want to continue connecting (yes/no)?
    +这是因为Git使用SSH连接,而SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入yes回车即可
    +Git会输出一个警告,告诉你已经把GitHub的Key添加到本机的一个信任列表里了
    Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
    +这个警告只会出现一次,后面的操作就不会有任何警告了
  16. 从远程仓库克隆
    $ git clone git@github.com:pfjhetg/gitskills.git
    +Cloning into 'gitskills'...
    +remote: Counting objects: 3, done.
    +remote: Total 3 (delta 0), reused 0 (delta 0)
    +Receiving objects: 100% (3/3), done.
    +
    +$ cd gitskills
    +$ ls
    +README.md
  17. 创建分支并且切换
    $ git checkout -b dev
    +Switched to a new branch 'dev'
    +-b 表示创建并且切换
    +等于下面两条命令
    $ git branch dev(创建)
    +$ git checkout dev(切换)
    +Switched to branch 'dev'
  18. 查看当前分支
    $ git branch
    +* dev
    +  master
  19. 合并指定分支(dev)到当前分支上
    $ git merge dev
    +Updating d17efd8..fec145a
    +Fast-forward
    + readme.txt |    1 +
    + 1 file changed, 1 insertion(+)
    +注意到上面的Fast-forward信息,Git告诉我们,这次合并是“快进模式”,也就是直接把master指向dev的当前提交,所以合并速度非常快,这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并
    $ git merge --no-ff -m "merge with no-ff" dev
    +Merge made by the 'recursive' strategy.
    + readme.txt |    1 +
    + 1 file changed, 1 insertion(+)
    +因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去
  20. 删除指定(feature1)分支 -d表示删除
    $ git branch -d feature1
  21. 查看分支合并情况
    $ git log --graph --pretty=oneline --abbrev-commit
    +*   59bc1cb conflict fixed
    +|\
    +| * 75a857c AND simple
    +* | 400b400 & simple
    +|/
    +* fec145a branch test
    +...
  22. bug 分支
    +当你接到一个修复一个代号101的bug的任务时,很自然地,你想创建一个分支issue-101来修复它,但是,等等,当前正在dev上进行的工作还没有提交:
    +将当前工作区储存起来,等恢复以后继续工作
    $ git stash
    +Saved working directory and index state WIP on dev: 6224937 add merge
    +HEAD is now at 6224937 add merge
    +查看以前的工作现场
    $ git stash list
    +stash@{0}: WIP on dev: 6224937 add merge
    +将存储起来的内容恢复(同时从list中删除)
    $ git stash pop
    +# On branch dev
    +# Changes to be committed:
    +#   (use "git reset HEAD <file>..." to unstage)
    +#
    +#       new file:   hello.py
    +#
    +# 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:   readme.txt
    +#
    +Dropped refs/stash@{0} (f624f8e5f082f2df2bed8a4e09c12fd2943bdd40)
    将存储起来的内容恢复(从list中读取,不删除)
    $ git stash apply stash@{0}
    +将存储起来的内容删除(从list中删除)
    $ git stash apply dropstash@{0}
  23. 强行删除分支
    $ git branch -D feature-vulcan
    +如果要丢弃一个没有被合并过的分支,可以通过git branch -D <name>强行删除。
  24. 查看远程分支的信息
    $ git remote -v
    +origin  git@github.com:michaelliao/learngit.git (fetch)
    +origin  git@github.com:michaelliao/learngit.git (push)
    -v 显示更详细的信息
  25. 打一个新的标签
    $ git tag v1.0
  26. 查看所有标签
    $ git tag
    +v1.0
  27. 根据某个提交id ,打新的标签
    $ git tag v0.9 6224937
  28. 查看标签信息
    $ git show v0.9
    +commit 622493706ab447b6bb37e4e2a2f276a20fed2ab4
    +Author: Michael Liao <askxuefeng@gmail.com>
    +Date:   Thu Aug 22 11:22:08 2013 +0800
    +
    +    add merge
    +...
  29. 创建带说明的标签
    $ git tag -a v0.1 -m "version 0.1 released" 3628164
    +-a 标签名
    +-m 说明
    +还可以通过-s用私钥签名一个标签
    $ git tag -s v0.2 -m "signed version 0.2 released" fec145
  30. 删除标签
    $ git tag -d v0.1
    +Deleted tag 'v0.1' (was e078af9)
  31. 推送单个标签到远程服务器
    $ git push origin v1.0
    +Total 0 (delta 0), reused 0 (delta 0)
    +To git@github.com:michaelliao/learngit.git
    + * [new tag]         v1.0 -> v1.0
    推送本地所有未推送的标签
    $ git push origin --tags
    +Counting objects: 1, done.
    +Writing objects: 100% (1/1), 554 bytes, done.
    +Total 1 (delta 0), reused 0 (delta 0)
    +To git@github.com:michaelliao/learngit.git
    + * [new tag]         v0.2 -> v0.2
    + * [new tag]         v0.9 -> v0.9
  32. 删除远程服务器上面的标签
    +先从删除本地标签
    $ git tag -d v0.9
    +Deleted tag 'v0.9' (was 6224937)
    +然后删除远程上的标签
    $ git push origin :refs/tags/v0.9
    +To git@github.com:michaelliao/learngit.git
    + - [deleted]         v0.9

  33. 创建SSH Key,在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,打开Shell,创建SSH Key
    $ ssh-keygen -t rsa -C "youremail@example.com"
    +注意:ssh和后面的"-"之间没有空格。
  34. https格式
    https://github.com/pfjhetg/learngit.git
    +git格式 +
    git@github.com:michaelliao/learngit.git
  35. Git本地库和远程库关联时候,需要保证本地主分支要commit进去了一个文件(库不能为空),否者无法提交上去并且提示
    +error: src refspec master does not match any.
    +error: failed to push some refs to 'git@github.com:pfjhetg/learngit.git'
  36. 工作区(Working Directory):就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工作区
  37. 版本库(Repository):工作区有一个隐藏目录.git,这个不算工作区,而是Git的版本库
  38. Git的版本库里存了很多东西,其中最重要的就是称为stage(或者叫index)的暂存区,还有Git为我们自动创建的第一个分支master,以及指向master的一个指针叫HEAD
  39. git中的当前分支泛指当前所在的分区
    +js@JS-PC ~/git/learngit (master)这里的master就是表示在主分区
  40. 从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交
  41. 在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致
  42. 建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name
  43. 从远程抓取分支,使用git pull,如果有冲突,要先处理冲突

+
\ No newline at end of file diff --git a/learngit/pinefantasy.txt b/learngit/pinefantasy.txt new file mode 100644 index 0000000000..7d38006134 --- /dev/null +++ b/learngit/pinefantasy.txt @@ -0,0 +1,9 @@ +To: +Michaelliao + +Thank you very much. +Your Git Course is Good. +A very Good Job for me. + +From: +A Java Engineer, pinefantasy diff --git a/learngit/piterator.txt b/learngit/piterator.txt new file mode 100644 index 0000000000..b903dc8f6f --- /dev/null +++ b/learngit/piterator.txt @@ -0,0 +1 @@ +thank you, teacher liao diff --git a/learngit/pq1949-leartgit-for-3q.txt b/learngit/pq1949-leartgit-for-3q.txt new file mode 100644 index 0000000000..c0bcfb9fc2 --- /dev/null +++ b/learngit/pq1949-leartgit-for-3q.txt @@ -0,0 +1 @@ +thank you! \ No newline at end of file diff --git a/learngit/pull-request-from-changsure.txt b/learngit/pull-request-from-changsure.txt new file mode 100644 index 0000000000..cd310726b1 --- /dev/null +++ b/learngit/pull-request-from-changsure.txt @@ -0,0 +1,3 @@ +It's really awesome here. + From changsure + diff --git a/learngit/pullrequest test b/learngit/pullrequest test new file mode 100644 index 0000000000..3c7526c74d --- /dev/null +++ b/learngit/pullrequest test @@ -0,0 +1 @@ +want to do a test for pullrequest diff --git a/learngit/pullrequest.txt b/learngit/pullrequest.txt new file mode 100644 index 0000000000..082626df32 --- /dev/null +++ b/learngit/pullrequest.txt @@ -0,0 +1 @@ +just for demostrate pull request \ No newline at end of file diff --git a/learngit/pxtj.txt b/learngit/pxtj.txt new file mode 100644 index 0000000000..6ae6aaa3c5 --- /dev/null +++ b/learngit/pxtj.txt @@ -0,0 +1,139 @@ +1.初始化仓库:git init +2. 往仓库中添加文件: + git add //将文件修改添加到暂存区 + git commit -m "文件说明" //将暂存区中的所有内容提交到当前分支 + +3. 查看仓库状态:git status +4. 比较文件的不同,或者查看文件修改的地方: + git diff + +5. 版本回退 + 查看历史记录:git log + 查看最近的某次的记录:git log -<数字> //查看最近的指定某次的记录 + 查看精简的历史记录:git log --pretty=oneline + 查看输入命令的记录:git reflog + 版本表示:当前版本表示为HEAD,上一个版本表示为HEAD^,上上个版本表示为HEAD^^ + 上100个版本可以表示为HEAD~100 + 版本回退:git reset --hard <版本id> 举例:git reset --hard HEAD^ //表示返回到上一个版本; + +6. 查看某一文件的内容:Linux命令,如 cat ,more等; +7. Git的工作区和暂存区 + (1)工作区(Working Direction):所编辑的文件所在的目录; + (2)版本库(Repository):工作区文件夹中的.git文件夹; + 方式:git add 将文件修改信息从工作区添加到暂存区; + git commit -m "说明" 将暂存区的信息添加到分支; +8. Git跟踪的文件的修改而不是文件本身:每次修改如果不add到暂存区,那么当commit提交时就不会添加到分支中。 +9. 撤销修改: + 命令:git checkout -- <文件名> 如:git checkout -- readme.txt + (1)当文件自修改后还没有被add到暂存区,则撤销修改就会使文件回到与版本库分支中的文件一模一样; + (2)当文件已经add到暂存区,又作了修改,则插销修改就会回到与暂存区中的文件一样; + 注:此命令中的 -- 一定要有,如果没有 -- 就变成创建一个新的分支; + + 当修改已经add到暂存区,此时想要撤销修改时,就需要先将暂存区的修改回退到工作区,然后再工作区撤销修改; + 命令:git reset HEAD <文件名> + git checkout -- <文件名> + 如:git reset HEAD readme.txt + git checkout -- readme.txt + + 当已经提交到版本库,想撤销修改时,就需要进行版本回退。 +10. 删除文件: + (1)若文件已经提交到版本库,从版本库中删除文件:git rm <文件名> + (2)若文件添加到暂存区,从暂存区中删除文件:git rm -f <文件名> + (3)若在工作区删除了文件,但文件已添加到暂存区或者提交到版本库中,在工作区中恢复文件:git checkout -- <文件名> +11. 创建SSH Key:ssh-keygen -t rsa -C "youremail@example.com" + 生成.ssh文件,其中id_rsa为私钥,id_rsa.pub为公钥。 + 将id_rsa.pub中的公钥添加到gitHub.com中。 +12. 将工程合并到github.com上:在github上创建项目,然后根据提示绑定; + 首先,关联一个远程库: + git remote add origin http://github.com/Username/Projectname.git 或者 //此处的origin为一个别名,可以取其他名字。 + git remote add origin git@github.com:path/repo-name.git + 然后,推送到远程库中:git push -u origin master //第一次推送master中的所有内容; + 此后,若本地版本修改之后,只需要通过git push origin master命令就可以合并到github.com中。 +13. 将仓库项目克隆到本地:git clone git@github.com:path/repo-name.git +14. 创建分支 + (1)创建分支:git checkout -b <分支名称> + 其中,参数-b相当于两条命令:创建并切换:git branch <分支名称>,git checkout <分支名称>; + 如:git checkout -b dev + 可以在创建本地分支的同时,将远程分支的内容克隆(clone)到此分支:git checkout -b <本地分支名> <远程库名称>/<远程分支名称>,如: + git checkout -b dev origin/dev //创建本地分支dev的同时,将远程origin库中的dev分支克隆到本地dev分支中。 + (2)查看当前分支:git branch //列出所有分支,并在当前分支前显示一个*; + (3)分支切换:git checkout <分支名称>// + (4)分支合并:git merge <分支名称> //将指定分支合并到当前分支上 + (5)删除分支:git branch -d <分支名称> //删除指定分支//删除本地分支; + (6)删除远程分支:git push origin :<分支名称>//删除远程服务器上的分支,:代表删除分支; +15. 当Git无法合并时,需要先手动解决冲突,然后再提交,在合并; + 查看分支合并图命令:git log --graph //多行显示提交记录 + 或者 git log --graph --pretty=oneline //单行显示合并及提交记录,但会显示每个记录id的全称 + 或者 git log --graph --pretty=oneline --abbrev-commit //单行显示,每个记录的Id只会显示一部分; +16. 分支管理 + 通常通过命令:git merge <分支名称>合并时,如果可能(比如没有冲突),Git会用Fast Forward模式,此种模式下,合并完成后,会丢失分支信息; + 可以通过禁用Fast Forward模式,Git就会在merge时生成一个新的commit,这样就可以从分支历史记录中看到分支信息; + 禁用Fast Forward模式的关键字为--no-ff,完整命令: + git merge --no-ff -m "说明" <分支名称> //因为要生成一个新的commit,所以用-m添加说明; +17. 分支策略 + 在实际开发中,应该按照以下几个原则进行分支管理: + (1)master分支应该是非常稳定的版本,也就是用来发布新版本,通常不在此分支开发; + (2)在dev分支上开发,将每个人的成果合并到dev上,然后通过dev合并到master上进行发布; + (3)每个人都有自己的分支,比如John,Sam等等,在自己的分支上开发,之后将其合并到dev分支上。 +18. bug分支 + (1)修复bug时通常在master中建一个临时分支,修复完成后,合并分支,然后将临时分支删除; +19. 任务现场“储存”操作 + 当工作进行到一半,需要立即处理其他事务,则可以通过任务现场“储存”操作将正在进行的工作暂时隐藏起来。 + 命令关键字为:stash + (1)git stash:备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区的内容保存到Git栈中。 + (2)git stash pop:显示Git栈内的所有备份,恢复工作区的相关内容。由于可能存在多个stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复; + (3)git stash list:显示Git栈内所有备份,可以利用这个列表来决定从哪个地方恢复; + (4)git stash clear:清空Git栈。此时使用gitg等图形化工具会发现,原来stash的那些节点都会消失。 + (5)git stash apply stash@{<标号>}:恢复Git栈中第<标号>所代表的内容;此命令不会从Git栈中删除此条存储信息。 + 若要删除,需要用git stash drop命令。 +20. feature分支: + 每添加一个功能,最好针对此功能新建一个分支,在分支上开发完成之后,在进行合并; + 如果未合并时需要删除,则可以通过 git branch -D <分支名称> 强制删除; +21. 多人协作 + (1)查看远程库名称:git remote 或者 git remote -v //可以显示更加详细的信息 + git branch -a//查看本地和远程分支; + (2)推送分支:git push origin <分支名称> //此命令默认将当前分支推送到远程的master上:如:git push origin master + 若要将本地master分支推送到远程的dev(远程已建立此分支),需要指定远程分支的名称,因为本地master分支默认指向origin master分支:git push origin master:<远程分支名称>,如:git push origin master:dev + 本地除master分支,推送到远程分支时,直接使用git push origin <远程分支名> 即可。 + (3)抓取分支:git pull + 当有人对远程分支中的某一文件做了修改,并已完成推送,本地也对此文件做了修改,再推送时会推送失败。需要先将远程库中的文件pull(拉取)到本地, + 然后在本地合并并解决冲突,再往远程推送。 + git pull作用:取回远程主机某个分支的更新,在与本地的指定分支合并; + 命令格式:git pull <远程主机名> <远程分支名>:<本地分支名> + 如:git pull origin next:master //取回远程origin主机的next分支,与本地的master分支合并 + 当远程分支与当前分支合并,冒号后面的部分可以省略; + git pull先取回,在合并,相当于先git fetch,再做git merge: + (4)建立跟踪关系 + Git可以自动在本地分支与远程分支之间,建立一种跟踪关系(tracking)。比如,在git cmaster分支lone时,所有本地分支默认与远程主机的同名分支,建立跟踪关系,也就是说,本地的master分支自动“追踪”origin/master分支。 + Git也可以手动建立跟踪关系:git branch --set-upstream <本地分支名> <远程主机名>/<远程分支名> + 如:git branch --set-upstream master origin/dev //指定本地master分支跟踪origin/dev分支。 + 如果当前分支与远程分支存在追踪关系,git pull就可以省略远程分支名称:git pull origin + 如果当前分支只有一个追踪分支,连远程主机名都可以省略:git pull //当前分支自动与唯一一个追踪分支合并; + 如果合并采用rebase模式,可以使用-rebase选项: + git pull --rebase <远程主机名> <远程分支名>:<本地分支名> + +22. 创建标签: + (1)创建命令:git tag ,如:git tag v1.0 + 查看所有标签:git tag + 注:默认标签是创建在最新提交的commit上的,需要早前的 commit打标签时,可用用commit的ID来打标签:git tag + (2)标签不是按照实际顺序列出而是按照字母排序。 + git show //查看标签信息; + (3)可以创建带有说明的标签,用-a指定标签名,-m指定说明文字。 + 如:git tag -a v0.1 -m "version 0.1 realeased" + 通过-s用私钥签名一个标签,如: + git tag -s v0.2 -m "signed version 0.2" + +23. 操作标签 + (1)删除标签:git tag -d ; + (2)创建的标签存储在本地,不会自动推送到远程,要将某个标签推送到远程,可以使用命令:git push origin + 一次性推送所有标签:git push origin --tags + (3)删除远程标签: + 先删除本地标签; + 然后通过命令:git push origin :refs/tags/ +24. 忽略特殊文件:https://github.com/github/gitignore + +25. 设置别名:git config --global alias.<别名> <命令名称> + 如:git config --global alias.st status //将status设置为st + +26. 配置文件: + (1)--global:针对当前用户起作用;如果不加,只针对当前的仓库起作用。 diff --git a/learngit/qcypggs@qq.com b/learngit/qcypggs@qq.com new file mode 100644 index 0000000000..933afcc3fa --- /dev/null +++ b/learngit/qcypggs@qq.com @@ -0,0 +1,2 @@ +Hi: + 你好,我是case,很高兴给你发这个消息,来验证我的学习所得,我在百度python,找到你的教程,然后又看git教程,这是我们见过的最好的git教程,没有之一。您的博客:提供原创中文精品教程,果然做到了,而且是精华级别,第一次想给开源作者赞助的。好了马屁拍完,再次感谢。 diff --git a/learngit/qidafang.txt b/learngit/qidafang.txt new file mode 100644 index 0000000000..da348f4aab --- /dev/null +++ b/learngit/qidafang.txt @@ -0,0 +1 @@ +thanks! \ No newline at end of file diff --git a/learngit/rafael.txt b/learngit/rafael.txt new file mode 100644 index 0000000000..c609407533 --- /dev/null +++ b/learngit/rafael.txt @@ -0,0 +1,92 @@ +Thanks you! + +$git init + 在指定目录下创建git仓库 repository +$git add readme.txt + 添加文件或者是提交修改到 stage(暂存区) +$git commit -m “commit changes" + 提交stage中的内容到本地版本库 +$git status + 查看rep的当前状态,包括工作区与暂存区 +$git diff + 查看工作区与仓库间的区别,如果工作区文件已添加到暂存区stage中,则忽略diff +$git log + 查看版本控制历史记录 +$git log —pretty=oneline + 单行显示历史记录 +$git reflog + 查看所有操作历史记录,包括回退记录 +$git reset —hard HEAD^ + 回退工作区上个版本 +$git reset —hard defiaw3io(版本 id) + 回退到指定版本id对应版本 +$git checkout — readme.txt + 丢弃工作区的修改(未提交到暂存区stage的修改) +$git reset HEAD readme.txt + 丢弃暂存区的修改unstage,重新放回工作区 + 区别与版本回退 git reset —hard HEAD^ +$git rm readme.txt + 删除文件,commit后生效 +$git checkout — readme.txt + 还未提交rm的情况下,可以撤销删除,恢复工作区文件 + +$git remote add origin “git site" + 把本地仓库与远程库相关联,origin就是远程库的名字,git默认,可修改。 +$git push -u origin master + 把本地库的内容推送到远程,由于是第一次推送master分支,所以加上了-u参数。 + git不但把本地master分支内容推送到远程新master分支,还会把本地的master + 分支和远程master分支关联起来。 + 之后push就不需要-u参数了。 +$git clone “remote rep site" + 克隆远程库到本地 + +分支部分: + +$git checkout -b dev + 创建分支(名称为dev),然后切换到dev分支 + -b表示创建并切换,相当于一下: + $git branch dev 创建dev分支 + $git checkout dev 切换到dev分支 +$git branch + 查看当前分支 +$git merge dev + 合并分支dev +$git branch -d dev + 删除分支 +$git branch -D dev + 强行删除分支 +$git log —graph + 查看分支合并图 +$git merge —no-ff -m “msg” dev + 禁用fast forward合并,保留分支合并信息 + +$git stash + 保存现场,转到其他分支 +$git stash list + 查看保存的现场list +$git stash apply + 恢复某现场 +$git stash pop + 恢复并删除某现场 +$git stash drop + 删除某现场 + +$git remote + 查看远程库信息 +$git remote -v + 远程库详细信息 +$git checkout -b dev origin/dev + 创建本地dev分支,对应远程dev分支 + +$git branch —set-upstream dev origin/dev + 创建本地与远程dev分支的链接 + +$git tag ’tagname' + 打标签 +$git tag + 查看标签 +$git tag ’tagname’ ‘commit id' + 对指定commit id对应提交打标签 +$git show 'tagname' + + diff --git a/learngit/readme.txt b/learngit/readme.txt new file mode 100644 index 0000000000..cb3cb7f285 --- /dev/null +++ b/learngit/readme.txt @@ -0,0 +1,10 @@ +Git is a distributed version control system. +Git is a free software distributed under the GPL. +Git has a mutable index called stage. +Git tracks changes of files. +Creating a new branch is quick and simple. +Git can merge branches. +"test pull request." +update by wk +update by frogy + diff --git a/learngit/recoba20.txt b/learngit/recoba20.txt new file mode 100644 index 0000000000..f1490d490f --- /dev/null +++ b/learngit/recoba20.txt @@ -0,0 +1 @@ +教程非常赞,我试试能不能pull? \ No newline at end of file diff --git a/learngit/redHL.txt b/learngit/redHL.txt new file mode 100644 index 0000000000..34db8573ed --- /dev/null +++ b/learngit/redHL.txt @@ -0,0 +1 @@ +不是很清楚标签的作用,标签管理上面可以再详细点。像分支管理就写得很详细。 \ No newline at end of file diff --git a/learngit/relsoul.txt b/learngit/relsoul.txt new file mode 100644 index 0000000000..70cb9a6cc6 --- /dev/null +++ b/learngit/relsoul.txt @@ -0,0 +1,243 @@ + + +本文是GitHub个人学习笔记. + +下载与安装GitHub + +下载 GitHub For Windows :https://windows.github.com/ + +PS:推荐架设VPN..下载和访问速度不忍直视啊 + + + +Git Shell + +创建版本库 + +在桌面打开Git Shell即进入了shell模式 + +新建文件夹>> mkdir初始化版本库>> git init + +添加文件 + +添加文件>>git add [file1 file2 file3...] + +提交文件到仓库>>git commit -m "第一次提交文件压力山大" + +回溯 + +查看是否存在改动未提交的文件>>git status + +查看文件改动信息>>git diff + +查看git改动日志>>git log + +简单显示git改动日志>>git log --pretty=oneline + +回溯git>>git reset --hard HEAD^ 一个^代表回溯到上一个版本^^两个回溯到上上个版本.... + +显示回溯日志>>git reflog + +回溯git(通过commit id)>>git reset --hard 3628164 + +工作区与暂存区详细说明:click + +git add提交说明 + +git做的是修改管理,修改包括.文件,动作 + +比如第一次我在readme.txt文件写了一行 + +hello world + +然后用git add命令进行添加,但是我突然想写一行 + +bey bey + +于是修改后不再次添加直接 git commit -m "xxx" + +然后再执行git status发现还有个readme.txt文件修改未被提交 + +原理很简单 + +第一次add添加的是hello world 这个文件放到了缓存区 + +然后你又添加了一行代码 beybey 于是这个文件又被放到了缓存区 + +也就是说缓存区有两个readme.txt + +理解了后就好办了,可以第一次修改的时候不add readme.txt + +或者第二次修改后再次使用 add readme.txt合并两个文件 再进行git commit -m添加 + +用git diff HEAD -- readme.txt命令可以查看工作区和版本库里面最新版本的区别: + +撤销修改 + +回到最近一次git commit或git add时的状态>>git checkout -- readme.txt + +添加到缓存区后撤销操作>>git reset HEAD file (然后再用checkout命令继续撤销) + +撤销添加到本地仓库未添加到远程仓库>>git reset --hard HEAD^ + + + +删除文件 + +从版本库中删除文件>>git rm flie + +接着再提交动作 git commit -m "删除一个文件" + + 远程仓库 + +添加远程库>>git remote add 代号(自行填写) git@github.com:你的账户名/仓库名.git + +错误提示:(本地已经存在这个远程仓库) fatal: remote origin already exists. +解决办法:(移除这个远程仓库) git remote rm origin +推送文件至远程库>>git push -u origin master + +PS:由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。 + +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; + +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; + +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + + 克隆远程库 + +git clone git@github.com:账户名/仓库名.git + + + +创建与合并分支 + +创建切换到dev分支>>git checkout -b dev + +git checkout命令加上-b参数表示创建并切换,相当于以下两条命令: + +$ git branch dev +$ git checkout dev +查看当前分支>>git branch (git branch命令会列出所有分支,当前分支前面会标一个*号) + +切换分支>>git checkout 分支名 + +合并分支>>git merge 分支名(移动到其他分支后使用此命令合并分支名) + +删除分支>>git branch -d 分支名 + + + +解决合并冲突 + +首先创建一个git checkout -b soul分支soul + +然后再readme.txt文件增加一行 + +soul readme + +提交一下readme.txt + +然后切换回master分支 + +然后修改master分支下的readme.txt + +master readme + +提交一下readme.txt + +然后执行一下合并git merge soul + +Auto-merging readme.txt +CONFLICT (content): Merge conflict in readme.txt +Automatic merge failed; fix conflicts and then commit the result. + +发现会报错 git无法执行快速合并 + +用git status也会提示冲突文件 + +于是我们需要手动处理 + +查看readme.txt文件 + +Git用<<<<<<<,=======,>>>>>>>标记出不同分支的内容 + +我们修改readme.txt文件 + +删除git生成的<<<<< ====== >>>>>>然后把test分支上readme.txt的内容添加到readme.txt里就ok了 + +然后git add readme.txt git commit -m "fix" + +分支管理策略 + +通常合并分支git都是使用Fast forward,但这种模式下,删除分支后,会丢掉分支信息 + +如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。 + +$ git merge --no-ff -m "merge with no-ff" dev + +Merge made by the 'recursive' strategy. readme.txt | 1 + + +1 file changed, 1 insertion(+) + +因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 + +Git分支十分强大,在团队开发中应该充分应用。 + +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + + + +Bug分支 + +比如我在dev分支下修改readme.txt时需要去master分支上修改一个bug + +于是我可以利用 + +储藏>>git stash + +当前的工作 然后切换至master上创建一个临时分支bugfix然后修改readme.txt + +修改完毕后git add readme.txt; git commit -m "fixbug" + +然后切换到master分支来 + +git merge --no-ff -m "merged bug fix 101" bugfix + +合并下bugfix 然后 + +git branch -d bugfix + +删除这个分支 + +切换到dev分支 + +工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: + +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; + +另一种方式是用git stash pop,恢复的同时把stash内容也删了:再用git stash list查看,就看不到任何stash内容了: + +利用 git stash pop恢复下内容 就可以继续工作了 + + + +强行删除分支 + +在未合并分支的情况下删除分支 + +git branch -d bugfix git会报错 + +于是我们可以使用 + +强行删除>>git branch -D (其实就把小写d改为大写D) + +然后就删除完毕了 + + 多人协作 + +真羡慕有两台电脑的人2333 + +详情去click me 这个网站观看~ + + \ No newline at end of file diff --git a/learngit/renguochao.txt b/learngit/renguochao.txt new file mode 100644 index 0000000000..c99ef0488a --- /dev/null +++ b/learngit/renguochao.txt @@ -0,0 +1,2 @@ +Thanks for your git blog, i learn a lot from it. +Writen by Guochao Ren. diff --git a/learngit/ryan_learn_git b/learngit/ryan_learn_git new file mode 100644 index 0000000000..6a94a34876 --- /dev/null +++ b/learngit/ryan_learn_git @@ -0,0 +1 @@ +Thank you liao~ diff --git a/learngit/sanbingo.txt b/learngit/sanbingo.txt new file mode 100644 index 0000000000..9130a58b16 --- /dev/null +++ b/learngit/sanbingo.txt @@ -0,0 +1 @@ +Stay hungry,Stay foolish! diff --git a/learngit/sanmisanFan.txt b/learngit/sanmisanFan.txt new file mode 100644 index 0000000000..c81c38c036 --- /dev/null +++ b/learngit/sanmisanFan.txt @@ -0,0 +1,6 @@ +Dear Michael, + +Hello, I am a postgraduate student and just start using git instead of SVN. +I have learned a lot from your amazing git tutorial. Thank you Michael! + +Sanmisan Fan diff --git a/learngit/sck-rookie.txt b/learngit/sck-rookie.txt new file mode 100644 index 0000000000..3fab02cdad --- /dev/null +++ b/learngit/sck-rookie.txt @@ -0,0 +1 @@ +The most wonderful tutorial i've ever seen! diff --git a/learngit/sdlyjzh.txt b/learngit/sdlyjzh.txt new file mode 100644 index 0000000000..25435c1a29 --- /dev/null +++ b/learngit/sdlyjzh.txt @@ -0,0 +1 @@ +Thank you a lot! It really helpful! diff --git a/learngit/seancy.txt b/learngit/seancy.txt new file mode 100644 index 0000000000..9218c7cccf --- /dev/null +++ b/learngit/seancy.txt @@ -0,0 +1,3 @@ + +这是我第二次学习廖雪峰老师的教程,此教程以通俗易懂的方式,从实用角度介绍了git的常用命令,如果你能通读这篇教程,使用git与人合作开发应该不成问题。推荐学习 + diff --git a/learngit/secondrocker.txt b/learngit/secondrocker.txt new file mode 100644 index 0000000000..cf645cd301 --- /dev/null +++ b/learngit/secondrocker.txt @@ -0,0 +1,2 @@ +my name is secondrocker +for the lich king diff --git a/learngit/sevengods.txt b/learngit/sevengods.txt new file mode 100644 index 0000000000..c8f20f9d35 --- /dev/null +++ b/learngit/sevengods.txt @@ -0,0 +1 @@ +一直在看廖老师的git教程,写的真好,谢谢廖老师的分享 diff --git a/learngit/sexy_tutorial.txt b/learngit/sexy_tutorial.txt new file mode 100644 index 0000000000..f6ed6f343e --- /dev/null +++ b/learngit/sexy_tutorial.txt @@ -0,0 +1,2 @@ +Great tutorial. cool! +Thanks Michael Liao. \ No newline at end of file diff --git a/learngit/sheisalwayswalking b/learngit/sheisalwayswalking new file mode 100644 index 0000000000..cc4d70af3b --- /dev/null +++ b/learngit/sheisalwayswalking @@ -0,0 +1,2 @@ +感谢廖老师得课程,感觉Git得功能真心很强大,~>_<~ +我会继续学习下去滴! diff --git a/learngit/shirleyChou.txt b/learngit/shirleyChou.txt new file mode 100644 index 0000000000..4971b22ca6 --- /dev/null +++ b/learngit/shirleyChou.txt @@ -0,0 +1 @@ +Your tutorial of learning git is a great and concise guidance for me. Thank you very much for that! diff --git a/learngit/shixiong77.txt b/learngit/shixiong77.txt new file mode 100644 index 0000000000..8b34b17f9d --- /dev/null +++ b/learngit/shixiong77.txt @@ -0,0 +1,3 @@ +Very good! +After read your blog for git,i'm trying use github.It's so easy and efficient. +Thanks a lot! diff --git a/learngit/shiyipingmi.txt b/learngit/shiyipingmi.txt new file mode 100644 index 0000000000..8711395c89 --- /dev/null +++ b/learngit/shiyipingmi.txt @@ -0,0 +1,3 @@ +Dear Michael Liao + Thanks for your great course.This is my first day on the job,My boss need to us to finish this course,and want us to +establish Ali cloud server.Oh ,my god ,I'm going crazy.Fortunately,there has your great course.Thanks sincely \ No newline at end of file diff --git a/learngit/sin-zx.txt b/learngit/sin-zx.txt new file mode 100644 index 0000000000..c595a691fd --- /dev/null +++ b/learngit/sin-zx.txt @@ -0,0 +1,4 @@ +# Thanks! Your course is lively and easy to learn how to use such a great tool. +# I have learned a lot. +# I am going on a way to be a great programmer like you.Hope i can do that. +# Thanks. diff --git a/learngit/sklthegoodman.txt b/learngit/sklthegoodman.txt new file mode 100644 index 0000000000..b2f882c03f --- /dev/null +++ b/learngit/sklthegoodman.txt @@ -0,0 +1 @@ +一个很棒的教程,浅显易懂,非常感谢!!!过几天购买ios app以示感谢。 \ No newline at end of file diff --git a/learngit/smallzzuni.txt b/learngit/smallzzuni.txt new file mode 100644 index 0000000000..0161bcd2c4 --- /dev/null +++ b/learngit/smallzzuni.txt @@ -0,0 +1 @@ +smallzzuni.txt test for learngit \ No newline at end of file diff --git a/learngit/smartoray.txt b/learngit/smartoray.txt new file mode 100644 index 0000000000..2d018a7981 --- /dev/null +++ b/learngit/smartoray.txt @@ -0,0 +1 @@ +Liao, thanks for your hard work! diff --git a/learngit/snowberry.txt b/learngit/snowberry.txt new file mode 100644 index 0000000000..1d33e34280 --- /dev/null +++ b/learngit/snowberry.txt @@ -0,0 +1,3 @@ +pull request +################# +一口气看完了,非常好的教程,通过图解的方式来说明,非常好,好的教程! diff --git a/learngit/soochowshanshan.txt b/learngit/soochowshanshan.txt new file mode 100644 index 0000000000..9bfc0aa798 --- /dev/null +++ b/learngit/soochowshanshan.txt @@ -0,0 +1,5 @@ +This is a test file from soochowshanshan. + +Thank you,liao. + +2015/05/26 diff --git a/learngit/stefancc_.txt b/learngit/stefancc_.txt new file mode 100644 index 0000000000..c41885994e --- /dev/null +++ b/learngit/stefancc_.txt @@ -0,0 +1 @@ +测试下是否支持中文的文件名 谢谢廖老师! \ No newline at end of file diff --git a/learngit/sulingzhi.txt b/learngit/sulingzhi.txt new file mode 100644 index 0000000000..b7cd1822d0 --- /dev/null +++ b/learngit/sulingzhi.txt @@ -0,0 +1,2 @@ + +my test \ No newline at end of file diff --git a/learngit/suweya.txt b/learngit/suweya.txt new file mode 100644 index 0000000000..0ff57a3fe7 --- /dev/null +++ b/learngit/suweya.txt @@ -0,0 +1 @@ +Thank you! \ No newline at end of file diff --git a/learngit/swead.txt b/learngit/swead.txt new file mode 100644 index 0000000000..5846941b4b --- /dev/null +++ b/learngit/swead.txt @@ -0,0 +1,3 @@ +It's a test. +Thanks you. +Swead \ No newline at end of file diff --git a/learngit/swk1992.txt b/learngit/swk1992.txt new file mode 100644 index 0000000000..d1f7a081e7 --- /dev/null +++ b/learngit/swk1992.txt @@ -0,0 +1 @@ +swk1992 \ No newline at end of file diff --git a/learngit/tangculijier.txt b/learngit/tangculijier.txt new file mode 100644 index 0000000000..dddc7b4f6b --- /dev/null +++ b/learngit/tangculijier.txt @@ -0,0 +1 @@ +Thanks! \ No newline at end of file diff --git a/learngit/teacher-Liao-is-a-good-teacher.txt b/learngit/teacher-Liao-is-a-good-teacher.txt new file mode 100644 index 0000000000..7cf09ffadb --- /dev/null +++ b/learngit/teacher-Liao-is-a-good-teacher.txt @@ -0,0 +1 @@ +thank you , teacher Liao. diff --git a/learngit/tedfortest.txt b/learngit/tedfortest.txt new file mode 100644 index 0000000000..2662fef898 --- /dev/null +++ b/learngit/tedfortest.txt @@ -0,0 +1 @@ +i want to say thank u for mr.liao for teaching me how to use git. \ No newline at end of file diff --git a/learngit/terryyeb.txt b/learngit/terryyeb.txt new file mode 100644 index 0000000000..8bd397ffc3 --- /dev/null +++ b/learngit/terryyeb.txt @@ -0,0 +1 @@ +廖老师的课程太棒了,得 赞助啊! diff --git a/learngit/test-AngiWANG.txt b/learngit/test-AngiWANG.txt new file mode 100644 index 0000000000..d86cee9781 --- /dev/null +++ b/learngit/test-AngiWANG.txt @@ -0,0 +1 @@ +ѧϰ״IJллṩƪ \ No newline at end of file diff --git a/learngit/test-pull-request b/learngit/test-pull-request new file mode 100644 index 0000000000..7aa51afad9 --- /dev/null +++ b/learngit/test-pull-request @@ -0,0 +1 @@ +hello michaelliao diff --git a/learngit/test.txt b/learngit/test.txt new file mode 100644 index 0000000000..ace28ac702 --- /dev/null +++ b/learngit/test.txt @@ -0,0 +1 @@ +thank you for your git article~ diff --git a/learngit/testGitPull.txt b/learngit/testGitPull.txt new file mode 100644 index 0000000000..5350da2875 --- /dev/null +++ b/learngit/testGitPull.txt @@ -0,0 +1 @@ +测试一下git推送,哈哈 diff --git a/learngit/test_abc.txt b/learngit/test_abc.txt new file mode 100644 index 0000000000..066a56554b --- /dev/null +++ b/learngit/test_abc.txt @@ -0,0 +1 @@ +教程写得通俗易懂,不错。谢谢! \ No newline at end of file diff --git a/learngit/test_for_pull_request.txt b/learngit/test_for_pull_request.txt new file mode 100644 index 0000000000..8e9c0da000 --- /dev/null +++ b/learngit/test_for_pull_request.txt @@ -0,0 +1,2 @@ +在这里尝试下贡献代码。 +谢谢你的文章,让我知道怎么使用git。 diff --git a/learngit/test_fork_1109.txt b/learngit/test_fork_1109.txt new file mode 100644 index 0000000000..306691a1f3 --- /dev/null +++ b/learngit/test_fork_1109.txt @@ -0,0 +1 @@ +good tutorial. \ No newline at end of file diff --git a/learngit/test_fork_pull.txt b/learngit/test_fork_pull.txt new file mode 100644 index 0000000000..9facc25238 --- /dev/null +++ b/learngit/test_fork_pull.txt @@ -0,0 +1,3 @@ +Forkܺpull reques +лƪ +л¥+1 \ No newline at end of file diff --git a/learngit/test_pull.txt b/learngit/test_pull.txt new file mode 100644 index 0000000000..45f4e185f2 --- /dev/null +++ b/learngit/test_pull.txt @@ -0,0 +1,2 @@ +this line has no contents. +test \ No newline at end of file diff --git a/learngit/test_pull_request_dee.txt b/learngit/test_pull_request_dee.txt new file mode 100644 index 0000000000..b95dfe7831 --- /dev/null +++ b/learngit/test_pull_request_dee.txt @@ -0,0 +1 @@ +这个git系列教程真的做得十分不错.深入浅出.谢谢博主. diff --git a/learngit/test_pull_request_ping.txt b/learngit/test_pull_request_ping.txt new file mode 100644 index 0000000000..1885550ce0 --- /dev/null +++ b/learngit/test_pull_request_ping.txt @@ -0,0 +1,5 @@ +Hi Mr Liao, +Your blog bring me a powerful benefit, thanks a lot. + +Best regards +Ping diff --git a/learngit/test_try_pull.txt b/learngit/test_try_pull.txt new file mode 100644 index 0000000000..9adbbc98b9 --- /dev/null +++ b/learngit/test_try_pull.txt @@ -0,0 +1 @@ +I just want to try. diff --git a/learngit/testbytpg.txt b/learngit/testbytpg.txt new file mode 100644 index 0000000000..c0bcfb9fc2 --- /dev/null +++ b/learngit/testbytpg.txt @@ -0,0 +1 @@ +thank you! \ No newline at end of file diff --git a/learngit/testpull b/learngit/testpull new file mode 100644 index 0000000000..b4b78d23ce --- /dev/null +++ b/learngit/testpull @@ -0,0 +1 @@ +what is this for ? diff --git a/learngit/thank b/learngit/thank new file mode 100644 index 0000000000..931e9f575f --- /dev/null +++ b/learngit/thank @@ -0,0 +1 @@ +谢谢作者 diff --git a/learngit/thank you b/learngit/thank you new file mode 100644 index 0000000000..4e8641e535 --- /dev/null +++ b/learngit/thank you @@ -0,0 +1 @@ +this is my first github fork,thank you. diff --git a/learngit/thank.you b/learngit/thank.you new file mode 100644 index 0000000000..e5408f3c41 --- /dev/null +++ b/learngit/thank.you @@ -0,0 +1,3 @@ +lucky to meet your article. +git is a good tool. +should be better. diff --git a/learngit/thankU.txt b/learngit/thankU.txt new file mode 100644 index 0000000000..2aef5541e3 --- /dev/null +++ b/learngit/thankU.txt @@ -0,0 +1 @@ +Thank you very much! \ No newline at end of file diff --git a/learngit/thanks b/learngit/thanks new file mode 100644 index 0000000000..45c3c6444d --- /dev/null +++ b/learngit/thanks @@ -0,0 +1,2 @@ +真的非常感谢这么用心良苦的教程。 +真的跟着操作一天学会,没有比这更简单的教程了。 \ No newline at end of file diff --git a/learngit/thanks.txt b/learngit/thanks.txt new file mode 100644 index 0000000000..2091cb07fa --- /dev/null +++ b/learngit/thanks.txt @@ -0,0 +1 @@ +thank you,Michael Liao. diff --git a/learngit/thanksforyou.txt b/learngit/thanksforyou.txt new file mode 100644 index 0000000000..9a9f07804b --- /dev/null +++ b/learngit/thanksforyou.txt @@ -0,0 +1 @@ +感谢楼主,终于搞明白git的使用了,能力大大提升!!! \ No newline at end of file diff --git a/learngit/thanksmichaelliao.txt b/learngit/thanksmichaelliao.txt new file mode 100644 index 0000000000..51b2c7d064 --- /dev/null +++ b/learngit/thanksmichaelliao.txt @@ -0,0 +1 @@ +thanks michaelliao \ No newline at end of file diff --git a/learngit/thankyou b/learngit/thankyou new file mode 100644 index 0000000000..ad5c99aa2d --- /dev/null +++ b/learngit/thankyou @@ -0,0 +1 @@ +thank you liao!I'm a student and start to learn git! diff --git a/learngit/thankyou.toyou b/learngit/thankyou.toyou new file mode 100644 index 0000000000..3ff757dac7 --- /dev/null +++ b/learngit/thankyou.toyou @@ -0,0 +1,6 @@ +t@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git + diff --git a/learngit/thankyou.txt b/learngit/thankyou.txt new file mode 100644 index 0000000000..584e62e760 --- /dev/null +++ b/learngit/thankyou.txt @@ -0,0 +1 @@ +Thanks for the wonderful tutorial! diff --git a/learngit/thankyou_txt b/learngit/thankyou_txt new file mode 100644 index 0000000000..19072713f7 --- /dev/null +++ b/learngit/thankyou_txt @@ -0,0 +1,2 @@ +thank you. +very much. diff --git a/learngit/theqwang.txt b/learngit/theqwang.txt new file mode 100644 index 0000000000..01aae4175a --- /dev/null +++ b/learngit/theqwang.txt @@ -0,0 +1,3 @@ +Hello liao +I am theqwang.Recently,I am learning Python and Git from your website. +without you,I can not grow up so fast.You are a good man,thank you very much! diff --git a/learngit/thk_you b/learngit/thk_you new file mode 100644 index 0000000000..76b0173826 --- /dev/null +++ b/learngit/thk_you @@ -0,0 +1 @@ +your blog is very useful for me ,thank you! diff --git a/learngit/tonylmd.txt b/learngit/tonylmd.txt new file mode 100644 index 0000000000..f402bcb593 --- /dev/null +++ b/learngit/tonylmd.txt @@ -0,0 +1,2 @@ +Thank a lot to liuxuefeng, the author of the Chinese version Git Tutorial. +This file is a part of my learning, trying to submit a pull request. diff --git a/learngit/truthpierce.txt b/learngit/truthpierce.txt new file mode 100644 index 0000000000..3d28bbb0eb --- /dev/null +++ b/learngit/truthpierce.txt @@ -0,0 +1,3 @@ +很棒的教程。从来没有系统学过,看到这个教程又重新过了一遍。非常感谢。 + +如果说有什么心得,就是教程里有些过时的内容。比如多人协作里--set-upstream参数已经不再适用,可以替换为--track或--set-upstream-to,希望能够及时更新。 diff --git a/learngit/tshua.txt b/learngit/tshua.txt new file mode 100644 index 0000000000..4625c62847 --- /dev/null +++ b/learngit/tshua.txt @@ -0,0 +1,2 @@ +我是一名大学生,学新东西的时候总是遇到选择的教材不合适,学习路线不合理等问题导致学习效率低下。 +非常感谢廖老师,您的教程很棒! \ No newline at end of file diff --git a/learngit/tuotuo.txt b/learngit/tuotuo.txt new file mode 100644 index 0000000000..a8bc975567 --- /dev/null +++ b/learngit/tuotuo.txt @@ -0,0 +1 @@ +谢谢你,你的博客写的非常好! diff --git a/learngit/turing369.txt b/learngit/turing369.txt new file mode 100644 index 0000000000..69fd529779 --- /dev/null +++ b/learngit/turing369.txt @@ -0,0 +1 @@ +just a test! diff --git a/learngit/tuzhis.txt b/learngit/tuzhis.txt new file mode 100644 index 0000000000..f6b9ea1f2b --- /dev/null +++ b/learngit/tuzhis.txt @@ -0,0 +1 @@ +thank you for your help diff --git a/learngit/tzp-github-1.txt b/learngit/tzp-github-1.txt new file mode 100644 index 0000000000..ea6411986f --- /dev/null +++ b/learngit/tzp-github-1.txt @@ -0,0 +1 @@ +My name is tzp,I am glad to see you. \ No newline at end of file diff --git a/learngit/uniquetree.txt b/learngit/uniquetree.txt new file mode 100644 index 0000000000..e1d79e59a5 --- /dev/null +++ b/learngit/uniquetree.txt @@ -0,0 +1,2 @@ +非常感谢廖老师这份git教程,我是看过其他教程再来看这份的,这让我会的再熟悉了一遍,也填补了我的不会的(例如pull request, +还让我亲身体验一番,nice)!Thanks you! diff --git a/learngit/uxzhou.txt b/learngit/uxzhou.txt new file mode 100644 index 0000000000..5e189d5ecb --- /dev/null +++ b/learngit/uxzhou.txt @@ -0,0 +1,5 @@ +Hi Michael Liao, + +I am UX Designer. This blog profoundly change my way of thinking in terms of github learning. + +You are really a great mentor. Thank you so much. I learned a lot. \ No newline at end of file diff --git a/learngit/vacing.txt b/learngit/vacing.txt new file mode 100644 index 0000000000..014e0c93c3 --- /dev/null +++ b/learngit/vacing.txt @@ -0,0 +1,6 @@ +Hello, everyone, + This is vacing, from uestc, at Nov 20th, 2014. + Very glad to learn this material, it's very useful. + Thank you cichaelliao. + Yours sincere + vacing diff --git a/learngit/very-good.txt b/learngit/very-good.txt new file mode 100644 index 0000000000..e66448f5ab --- /dev/null +++ b/learngit/very-good.txt @@ -0,0 +1 @@ +Nice! diff --git a/learngit/veyron1110.txt b/learngit/veyron1110.txt new file mode 100644 index 0000000000..b6d738f5d5 --- /dev/null +++ b/learngit/veyron1110.txt @@ -0,0 +1,5 @@ +Hi sir, + +Your tutorial is so great that I can't resist to recommend it to my friends. + +Best diff --git a/learngit/vincent-wjj.txt b/learngit/vincent-wjj.txt new file mode 100644 index 0000000000..0fa29d093a --- /dev/null +++ b/learngit/vincent-wjj.txt @@ -0,0 +1 @@ +As for a work,I study you toturial! Thanks a lot for these wonderful feeds! diff --git a/learngit/vincentping.txt b/learngit/vincentping.txt new file mode 100644 index 0000000000..7021a28189 --- /dev/null +++ b/learngit/vincentping.txt @@ -0,0 +1 @@ +Thanks you for the git tutorial! diff --git a/learngit/vinson0420@163.com.txt b/learngit/vinson0420@163.com.txt new file mode 100644 index 0000000000..467767e5fb --- /dev/null +++ b/learngit/vinson0420@163.com.txt @@ -0,0 +1,2 @@ +Thank you for giving so good a session. +I like it! diff --git a/learngit/voidmous.txt b/learngit/voidmous.txt new file mode 100644 index 0000000000..7eaa770069 --- /dev/null +++ b/learngit/voidmous.txt @@ -0,0 +1,2 @@ +很漂亮的教程,一个上午学完,感谢! +20块钱请你吃个夜宵,微信ID:voidmous diff --git a/learngit/volterra.txt b/learngit/volterra.txt new file mode 100644 index 0000000000..1421718f68 --- /dev/null +++ b/learngit/volterra.txt @@ -0,0 +1 @@ +Thanks Mr.Liao! Really meaningful and awesome work! diff --git a/learngit/vra.txt b/learngit/vra.txt new file mode 100644 index 0000000000..30b6463371 --- /dev/null +++ b/learngit/vra.txt @@ -0,0 +1,3 @@ +This is thankyou file from vra +Thank you sincerely. + diff --git a/learngit/w10001.txt b/learngit/w10001.txt new file mode 100644 index 0000000000..7ec9a4b774 --- /dev/null +++ b/learngit/w10001.txt @@ -0,0 +1 @@ +aa \ No newline at end of file diff --git a/learngit/wangshui26.txt b/learngit/wangshui26.txt new file mode 100644 index 0000000000..458055f5ea --- /dev/null +++ b/learngit/wangshui26.txt @@ -0,0 +1 @@ +中午好啊...... \ No newline at end of file diff --git a/learngit/wangxiaobupt.txt b/learngit/wangxiaobupt.txt new file mode 100644 index 0000000000..851a8271fb --- /dev/null +++ b/learngit/wangxiaobupt.txt @@ -0,0 +1,5 @@ +Thank you so much . + +I have learned a lot and it make me happy . + + diff --git a/learngit/wangzhizhou2014GitHub.txt b/learngit/wangzhizhou2014GitHub.txt new file mode 100644 index 0000000000..d9bdb4733a --- /dev/null +++ b/learngit/wangzhizhou2014GitHub.txt @@ -0,0 +1,10 @@ +Git is very interesting. + +Thanks for your hardwork that let me mastered a new skill. + +The first time I know the GitHub when I read a book named "Orange S: The implement of an operating system" which written by a Chinese named YuYuan. Then I search on the internet for the new term. Fortunately, I found your tutorial for Git. After one hour reading, I found that I love the powerful software and your style of writing. Thank you again! + +And when I write this letter, you know I will read over your tutorial about git no longer. + +I just want to say: Thank you very much! +I will let more people know your tutorial and you web site. diff --git a/learngit/wangzhizhou2014GitHub_2 b/learngit/wangzhizhou2014GitHub_2 new file mode 100644 index 0000000000..300fa0adde --- /dev/null +++ b/learngit/wangzhizhou2014GitHub_2 @@ -0,0 +1,8 @@ +This is my second time to study your git tutorial, and I reach the topic "Use GitHub" again. +This time I get more knowledge about git not only from your tutorial, but also from a book named "Pro Git". +After compared your tutorial and that book, I still think yours are better, though that book digs deeper in the inner rules that git follow. + +And I decide to read you tutorial the third time after I digest that harder book. +I believe that I will contribute something to your tutorial at that time. +Because I really want to do something to let other people accept git more quickly and widely as well as easily. +At this point, I think we each other can join our hands. diff --git a/learngit/wdkwdkwdk.txt b/learngit/wdkwdkwdk.txt new file mode 100644 index 0000000000..a76aa34ca0 --- /dev/null +++ b/learngit/wdkwdkwdk.txt @@ -0,0 +1 @@ +git is useful and fun~ \ No newline at end of file diff --git a/learngit/wellstang.txt b/learngit/wellstang.txt new file mode 100644 index 0000000000..38b8f4bdab --- /dev/null +++ b/learngit/wellstang.txt @@ -0,0 +1 @@ +作为一名git的初学者,这是我读过最简单明了、通俗易懂的入门教程,大赞。 \ No newline at end of file diff --git a/learngit/whatit.txt b/learngit/whatit.txt new file mode 100644 index 0000000000..ec340dafcb --- /dev/null +++ b/learngit/whatit.txt @@ -0,0 +1 @@ +What's it? diff --git a/learngit/wideunique.txt b/learngit/wideunique.txt new file mode 100644 index 0000000000..b46118e105 --- /dev/null +++ b/learngit/wideunique.txt @@ -0,0 +1,2 @@ +hello,I am wideunique!!!!! +thanks for Liao XueFeng!!! \ No newline at end of file diff --git a/learngit/wikinee.MD b/learngit/wikinee.MD new file mode 100644 index 0000000000..b5a492105f --- /dev/null +++ b/learngit/wikinee.MD @@ -0,0 +1,6 @@ +#PULL REQUEST 测试 +以前看到了廖老师的官方网站,之后发现imooc网上还有视屏教程。 +后来找了很久,发现有人把python和git教程都生成了epub的电子书,离线看很好。 +对应mooc网的,我觉得给的提示代码太多了。 +另外,由于有些答案前后会有联系,在后面的答案放上前边的连接,我想会更好。 +谢谢 \ No newline at end of file diff --git a/learngit/wind123.txt b/learngit/wind123.txt new file mode 100644 index 0000000000..cb3a143171 --- /dev/null +++ b/learngit/wind123.txt @@ -0,0 +1 @@ +thank you,liao! diff --git a/learngit/wjcccc-Javaer.txt b/learngit/wjcccc-Javaer.txt new file mode 100644 index 0000000000..cc37639c40 --- /dev/null +++ b/learngit/wjcccc-Javaer.txt @@ -0,0 +1,2 @@ +It`s told by my friend that there`s a blog that teaches git and then I browsed yeaterday,and I found that it was so easy to learn git according to your blog,that is amazing! +I spent 2 days to have a glance at this blog and had known how it worked,thanks to your blog! \ No newline at end of file diff --git a/learngit/wjk.txt b/learngit/wjk.txt new file mode 100644 index 0000000000..3b18e512db --- /dev/null +++ b/learngit/wjk.txt @@ -0,0 +1 @@ +hello world diff --git a/learngit/wjm3219.txt b/learngit/wjm3219.txt new file mode 100644 index 0000000000..5a66d07cf4 --- /dev/null +++ b/learngit/wjm3219.txt @@ -0,0 +1,6 @@ +接触github接近一年了 +之前都是直接在网站上查看源代码和下载编译好的工具用 +一直都没接触到用git工具来对自己fork过的源码进行clone和commit +廖大大的教程写得蛮好,基本熟悉了git与github的关系 +也学会了如何通过git去clone源代码到本地、commit修改后代码至github +非常感谢~ \ No newline at end of file diff --git a/learngit/wlkhqc.txt b/learngit/wlkhqc.txt new file mode 100644 index 0000000000..7384e930d7 --- /dev/null +++ b/learngit/wlkhqc.txt @@ -0,0 +1,3 @@ +Thank you so much,liao. +It's the simplest and useful tutorial I have read,you let me know about git. +Thanks again. diff --git a/learngit/wukk.txt b/learngit/wukk.txt new file mode 100644 index 0000000000..cd9656b00a --- /dev/null +++ b/learngit/wukk.txt @@ -0,0 +1 @@ +i love you!!! \ No newline at end of file diff --git a/learngit/wwangaz.txt b/learngit/wwangaz.txt new file mode 100644 index 0000000000..af5f38882a --- /dev/null +++ b/learngit/wwangaz.txt @@ -0,0 +1,3 @@ +Thank you very much! michaelliao +I learn a lot on you website both on python and git. +And it is my first time donate on the internet just like buy a book. \ No newline at end of file diff --git a/learngit/wwz.txt b/learngit/wwz.txt new file mode 100644 index 0000000000..db809f3711 --- /dev/null +++ b/learngit/wwz.txt @@ -0,0 +1 @@ +wwz pull request test diff --git a/learngit/wyy b/learngit/wyy new file mode 100644 index 0000000000..dd62c0a103 --- /dev/null +++ b/learngit/wyy @@ -0,0 +1 @@ +testfile wyy diff --git a/learngit/wzy-xinde.php b/learngit/wzy-xinde.php new file mode 100644 index 0000000000..f582a6bd0a --- /dev/null +++ b/learngit/wzy-xinde.php @@ -0,0 +1,6 @@ + diff --git a/learngit/wzy.txt b/learngit/wzy.txt new file mode 100644 index 0000000000..50c551bc03 --- /dev/null +++ b/learngit/wzy.txt @@ -0,0 +1 @@ +可以出书了 \ No newline at end of file diff --git a/learngit/xbox360.txt b/learngit/xbox360.txt new file mode 100644 index 0000000000..c872184fae --- /dev/null +++ b/learngit/xbox360.txt @@ -0,0 +1 @@ +good job! \ No newline at end of file diff --git a/learngit/xiangtao_go@163.com b/learngit/xiangtao_go@163.com new file mode 100644 index 0000000000..e8e6577231 --- /dev/null +++ b/learngit/xiangtao_go@163.com @@ -0,0 +1,2 @@ +Thank your git lession.it is very good for me. +it makes me understand how it work. diff --git a/learngit/xiaocunz.txt b/learngit/xiaocunz.txt new file mode 100644 index 0000000000..12e30da3e3 --- /dev/null +++ b/learngit/xiaocunz.txt @@ -0,0 +1,2 @@ +Through 4 days learn git,I think git is really a good version control system. +Thanks michaelliao for teaching me. \ No newline at end of file diff --git a/learngit/xiaofeng.txt b/learngit/xiaofeng.txt new file mode 100644 index 0000000000..970ad5ca15 --- /dev/null +++ b/learngit/xiaofeng.txt @@ -0,0 +1 @@ +xiaofengfeng hello study \ No newline at end of file diff --git a/learngit/xiaofuyesnew.txt b/learngit/xiaofuyesnew.txt new file mode 100644 index 0000000000..6db58449ea --- /dev/null +++ b/learngit/xiaofuyesnew.txt @@ -0,0 +1,5 @@ +非常感谢廖老师的git教程,让我从一个git的门外汉在短短两天时间里面学会怎么使用git。 +虽然现在我的IT知识还很有限,但是我还是希望通过自己的努力成为像廖老师一样的IT达人。 +还有很多不懂的问题,还要向廖老师学习。我相信一定能做到。 +谢谢廖老师给我们提供了一个实际操作的平台。 +xiaofuyesnew 2015年1月4日 diff --git a/learngit/xiaoke040.markdown b/learngit/xiaoke040.markdown new file mode 100644 index 0000000000..d550cf7559 --- /dev/null +++ b/learngit/xiaoke040.markdown @@ -0,0 +1,10 @@ + +非常抱歉 +默认是ANSI编码 +嗯哼,我再找找详细的教程看看 +昨天学的东西又忘了 + + +===== +做新手教程很好,还在学习中 +还是不太熟悉啊 diff --git a/learngit/xiaoshan.txt b/learngit/xiaoshan.txt new file mode 100644 index 0000000000..364d384e1c --- /dev/null +++ b/learngit/xiaoshan.txt @@ -0,0 +1 @@ +Thank you teacher Liao! \ No newline at end of file diff --git a/learngit/xinghun.txt b/learngit/xinghun.txt new file mode 100644 index 0000000000..9e7e1bffce --- /dev/null +++ b/learngit/xinghun.txt @@ -0,0 +1,3 @@ +的确是很不错的一篇教程,看过的Git教程中最好的一篇了。 +之前看其他教程看一小会就看不下去了,所以也一直没学会Git。 +今天看了一上午这个教程,终于学会Git了。 \ No newline at end of file diff --git a/learngit/xiniu.txt b/learngit/xiniu.txt new file mode 100644 index 0000000000..4144bdccae --- /dev/null +++ b/learngit/xiniu.txt @@ -0,0 +1,17 @@ +花了两天时间,阅读了廖雪峰先生的整个教程,对Git以及GitHub有了 +基本的了解,掌握了一些Git的常用操作。写了一下新得与体会,顺便 +实验下pull request操作: +1.Git是一个分布式的版本控制系统,GitHub是一个开放式的代码托管 +平台; +2.我们可以在GitHub上fork一个项目,然后在个人PC上为该项目修改和 +贡献代码,最后通过pull request操作请求项目的拥有者添加进去你的 +代码; +3;Git的命令行控制方式和Linux系统很像啊; +4暂存区的概念很重要,可以帮你理解“git add”和‘git commit’操作; +5分支的优越性:我们通常只把自己的改写合并到dev上,而不是master; +这样做既可以使各开发者工作互不干扰,能够随时提交,还能维护已发 +布的最新版本; +6个人感觉checkout 这个命令很容易混淆: + eg:git checkout -- readme.txt //撤销工作区的修改 + git checkout -b dev //新建了一个分支dev,并跳转到该分支 + git checkout master //重新回到主分支 \ No newline at end of file diff --git a/learngit/xrfinbupt.txt b/learngit/xrfinbupt.txt new file mode 100644 index 0000000000..d3df1f8ab3 --- /dev/null +++ b/learngit/xrfinbupt.txt @@ -0,0 +1,8 @@ + +1 谢谢你结合案例把git的用法讲的很清楚 + +2 让我清晰的知道git与SVN的区别 + +3 记住了git的index概念,分支的细节 + +4 下一次我一定把你写的Python看一下,thx from 校友 diff --git a/learngit/xunyl.txt b/learngit/xunyl.txt new file mode 100644 index 0000000000..b0c8225806 --- /dev/null +++ b/learngit/xunyl.txt @@ -0,0 +1,4 @@ +Thank you so much for your course! + +by xunyl +2015-4-5 Sun. diff --git a/learngit/yangshuo.txt b/learngit/yangshuo.txt new file mode 100644 index 0000000000..74cd769ccd --- /dev/null +++ b/learngit/yangshuo.txt @@ -0,0 +1,5 @@ +At first thanks Mr. Liao very much. Your course is the best one after I have saw many courses about git. +I just want to tell the other people who want to learn git that you just need to use less than 5 hours and follow the course step by step you won't afraid of git anymore! + +test! + diff --git a/learngit/yangyang.txt b/learngit/yangyang.txt new file mode 100644 index 0000000000..51a77cc8a7 --- /dev/null +++ b/learngit/yangyang.txt @@ -0,0 +1 @@ +very very very good ,thank you! diff --git a/learngit/yccphp@163.com b/learngit/yccphp@163.com new file mode 100644 index 0000000000..184e35208a --- /dev/null +++ b/learngit/yccphp@163.com @@ -0,0 +1,252 @@ + + + +git init + 命令把这个目录变成git 可以管理的仓库 + +git add 文件名 + 把文件添加到仓库 + + +git status + git 仓库的状态 + + +git commit -m "add readme.text file” + + 把文件提交到仓库 + + -m 是本次的提交说明 + +git diff readme.txt + + 查看文件修改内容 + +git log + 查看版本提交记录 + + --pretty=oneline 只显示版本号和提交注视 + + +在 git 中,当前版本用 HEAD 表示,上一个版本是 HEAD^ ,上上个版本是 HEAD^^ + +往上 100 个版本就是 100 个 ^ ,难写,所以写成 HEAD~100 + + +git reset --hard HEAD^ + + 回到上一个版本 + +git reset --hard eb7378897e8996f1e + + 根据版本号回到此版本 + +git reflog + + 查看每一次的版本id + +git diff HEAD -- readme.txt + + 查看工作区与版本库里面的文件区别 + + + + + + +git checkout -- readme.txt + + 把 readme.txt 文件在工作区的修改全部撤销 + + 1、如果文件修改后,还没有放到暂寸区,撤销后,和版本的一样 + 2、如果文件已经放到暂存区,撤销户,回到暂存区的状态 + + +git reset HEAD readme.txt + + 把暂存区的文件撤销掉,重新放回工作区 + + +git rm test.php + + 删除版本库里面的文件,需要再次 commit + + + + + +生成 ssh key + + ssh-keygen -t rsa -C “youremail@example.com" + + 一路默认 + + /Users/yuanchao/.ssh 里面保存了生成的 key .pub 是公钥 + + + + +添加远程仓库 + + 在 git 新建一个仓库 + + 把这个仓库与本地仓库关联 + git remote add origin git@github.com:yccphp/testgit.git (每个仓库不同) + + + 把我们本地仓库的所有内容推送到远程库 + git push -u origin master (第一次) + + 以后每次提交 + git push origin master + + + + + + + + + +从远程仓库克隆 + + + git clone git@github.com:yccphp/gitclonetest.git + + 不同的 git 不同的地址 + + 然后修改后,需要推送的话,还是使用推送命令 push + + +创建合并分支 + + + checkout -b 分支名 + + -b 表示创建并且切换 + +git branch 分支名 + + 创建一个分支 + + +git checkout 分支名 + + 切换到某个分支 + +git branch + + 查看当前分支 + + + +git merge dev + + 合并指定分支 到当前分支上 + +git branch -d dev + + 删除指定分支 + + +git log --graph --pretty=oneline -—abbrev-commit + + 查看分支合并情况 + + +git merge --no-ff -m "merge with on-ff" dev + + 合并创建一个新的提交 + + —no-ff 普通合并,合并后的历史有分支,能看的出来曾经做过合并 + + + + +bug 分支 + +当你接到一个修复一个代号101的bug的任务时,很自然地,你想创建一个分支issue-101来修复它,但是,等等,当前正在dev上进行的工作还没有提交: + + + +git stash + + 将当前工作区储存起来,等恢复以后继续工作 + + +git stash pop + 将存储起来的内容,恢复 + + +强行删除分支 + git branch -D feature-vulcan + + 如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 + + + +git remote + + -v 显示更详细的信息 + + 查看远程分支的信息 + + + + +标签 + + + +切换到需要打标签的分支上 + + +git tag + + 打一个新的标签 标签名 + +git tag + + 查看所有标签 + + +git tag v789 7a7e436 + + 根据某个提交id ,打新的标签 + +git show v789 + 查看标签信息 + + +git tag -a dev1.0 -m “开发版" + + -a 标签名 + -m 说明 + + +git tag -d + + 删除标签 标签名 + + +git push origin v1.0 + + 推送标签到远程服务器 + + +git push origin —tags + + 推送本地所有未推送的标签 + + +删除远程服务器上面的标签 + +1、先从本地删除 + + git tag -d v789 + +2、删除远程上的tag + + git push origin :refs/tags/v0.9 + + diff --git a/learngit/your-github-enhedalai.txt b/learngit/your-github-enhedalai.txt new file mode 100644 index 0000000000..9cc39d95a2 --- /dev/null +++ b/learngit/your-github-enhedalai.txt @@ -0,0 +1 @@ +git diff --git a/learngit/your-github-id.txt b/learngit/your-github-id.txt new file mode 100644 index 0000000000..66dcf50ac9 --- /dev/null +++ b/learngit/your-github-id.txt @@ -0,0 +1,8 @@ +一口气全部看完了,讲得很详细很有黑皮书的感觉。硬是要说缺点的话就是github的多人合作介绍得不够具体。 +我对github上的协作是这样理解的:fork就好比转载别人的文章,因为不转载是没有权限修改的。而转载后在自己的地盘想怎样就怎样。然后要把别人的文章下载到自己电脑上修改,这个就是clone。在自己电脑上修改完成后保存就是git add和git commit。想要发表到网上就是git push。发表了想让作者添加你的修改就得向作者提交请求,让作者知道你改了什么,这个就是pull request +//工作区,缓存区,仓库和github这些还没想到比较好的比喻 +//用了your-github-id.txt这个文件名一定会被拒绝吧= = +thank you very much!!! +直接在your-github-id.txt中修改,然后推送一下看看我的内容有没有推送成功,哈哈!From:mailtohwj@gmail.com。 +test +教程非常赞,我试试能不能pull? diff --git a/learngit/your-github-whatswhat.txt b/learngit/your-github-whatswhat.txt new file mode 100644 index 0000000000..b3e404237a --- /dev/null +++ b/learngit/your-github-whatswhat.txt @@ -0,0 +1,189 @@ + + + + + +$ git init 初始化一个Git仓库 + +添加文件到Git仓库,分两步: +$ git add +$ git commit -m "....." + +$ git status + +$ git diff #比较工作区和暂存区文件差异 (Working Directory工作区(add操作前) 和 stage暂存区(add操作后) 的区别) +$ git diff HEAD -- 查看工作区和版本库里面最新版本的区别(Working Directory工作区(add操作前) 和 Repository版本库(commit操作后) 的区别) + + +版本回退: +$ git reset --hard +$ git reset --hard HEAD^ +首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交3628164...882e1e0(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。 + + +$ git log 查看提交历史 +$ git log --pretty=oneline + +$ git reflog 查看命令历史 + + + * +HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 + * +穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 + * +要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本 + + + +撤销修改: +$ git checkout -- readme.txt 把readme.txt文件在工作区的修改全部撤销 丢弃工作区的修改 +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +总之,就是让这个文件回到最近一次git commit或git add时的状态。 + +$ git reset HEAD file 把暂存区的修改撤销掉(unstage),重新放回工作区 + + +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + +远程仓库 +$ git push -u origin master +$ git push origin master + + +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +从远程库克隆: +$ git clone git@github.com:whatswhat/gitskills.git 后面是仓库的地址 ssh(速度快) +$ git clone https://github.com/whatswhat/gitskills.git 后面是仓库的地址 http + +分支管理 +创建与合并分支 + + +查看分支:git branch +创建分支:git branch +切换分支:git checkout +创建+切换分支:git checkout -b +合并某分支到当前分支:git merge +删除分支:git branch -d +解决冲突、分支管理策略 +用git log --graph命令可以看到分支合并图 +$ git log --graph --pretty=oneline --abbrev-commit + + + +通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。--no-ff方式的git merge: 准备合并dev分支,请注意--no-ff参数,表示禁用Fast forward: +$ git merge --no-ff -m "merge with no-ff" dev + + +Bug分支 +Git还提供了一个stash功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作: +$ git stash +$ git stash list + + +工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +$ git stash apply + +$ git stash pop + + + +你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,用命令: + +$ git stash apply stash@{0} + + + +小结 +修复bug时,我们会通过创建新的bug分支进行修复,然后合并,最后删除; +当手头工作没有完成时,先把工作现场git stash一下,然后去修复bug,修复后,再git stash pop,回到工作现场。 + +Feature分支 + +开发一个新feature,最好新建一个分支; +如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 + +多人协作 + + +当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应起来了,并且,远程仓库的默认名称是origin。 +$ git remote 查看远程库的信息 +$ git remote -v 显示更详细的信息(显示可以抓取fetch和推送push的origin的地址) + +推送分支 +推送分支,就是把该分支上的所有本地提交推送到远程库。推送时,要指定本地分支,这样,Git就会把该分支推送到远程库对应的远程分支上: +$ git push origin master +如果要推送其他分支,比如dev,就改成: +$ git push origin dev + +并不是一定要把本地分支往远程推送,那么,哪些分支需要推送,哪些不需要呢? + + * +master分支是主分支,因此要时刻与远程同步; + * +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + * +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + * +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + +总之,就是在Git中,分支完全可以在本地自己藏着玩,是否推送,视你的心情而定! + +抓取分支 +$ git checkout -b dev origin/dev 创建远程origin的dev分支到本地 +$ git branch --set-upstream dev origin/dev 设置本地dev分支与远程origin/dev分支的链接 +$ git pull 把最新的提交从远程origin/dev抓下来 + + +多人协作的工作模式通常是这样: + + 1. +首先,可以试图用git push origin branch-name推送自己的修改; + 2. +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + 3. +如果合并有冲突,则解决冲突,并在本地提交; + 4. +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + + +小结 + + * +查看远程库信息,使用git remote -v; + * +本地新建的分支如果不推送到远程,对其他人就是不可见的; + * +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + * +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + * +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + * +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + +标签管理 +创建标签 +$ git tag 新建一个标签(需先切换到要打标签的分支上)(默认为HEAD,也可以指定一个commit id) +$ git tag -a -m "…" 指定标签信息 +$ git tag -s -m “…" 用PGP签名标签(如果报错,请参考GnuPG帮助文档配置Key。) +$ git tag 查看所有标签 +$ git show 查看标签信息 + +操作标签 +$ git tag -d 删除一个本地标签 +$ git push origin 推送一个本地标签 +$ git push origin --tags 一次性推送全部未推送到远程的本地标签 +$ git push origin :refs/tags/ (从远程删除)删除一个远程标签(需先从本地删除即先执行git tag -d 命令) diff --git a/learngit/your_github-charliecen.txt b/learngit/your_github-charliecen.txt new file mode 100644 index 0000000000..3cd3ed3d2c --- /dev/null +++ b/learngit/your_github-charliecen.txt @@ -0,0 +1,7 @@ +第一次真正全面看git教程,简洁而容易理解。对新手的我来说帮助很大。 + +俺现在生产环境还在用svn,看来是不是该丢了。嘿嘿! + +看完一次再看第二次理解会更深刻。 + +谢谢大神的git教程。 diff --git a/learngit/youshihou.txt b/learngit/youshihou.txt new file mode 100644 index 0000000000..b88c055cad --- /dev/null +++ b/learngit/youshihou.txt @@ -0,0 +1,9 @@ +#include + +int main() +{ + printf("hello git"); + + return 0; + +} diff --git a/learngit/youzi.txt b/learngit/youzi.txt new file mode 100644 index 0000000000..35539714d0 --- /dev/null +++ b/learngit/youzi.txt @@ -0,0 +1 @@ +博主实在是太酷了,真的是设身处地的以初学者的思维写就博客的.博主让我对以前一点不感兴趣的编程产生了浓厚的兴趣.真的是万分感谢,我会时不时的小额资助博主的. diff --git a/learngit/yoyoyo.txt b/learngit/yoyoyo.txt new file mode 100644 index 0000000000..7315c41cdc --- /dev/null +++ b/learngit/yoyoyo.txt @@ -0,0 +1 @@ +真是不错的教程呢? 看着根本停不下来 现在都晚上3点了 - - 棒棒哒 \ No newline at end of file diff --git a/learngit/zhanba.txt b/learngit/zhanba.txt new file mode 100644 index 0000000000..c8bb1f5ce5 --- /dev/null +++ b/learngit/zhanba.txt @@ -0,0 +1,2 @@ +pull request! +Great job!Thank you! \ No newline at end of file diff --git a/learngit/zhangdongwei.txt b/learngit/zhangdongwei.txt new file mode 100644 index 0000000000..b1ddcd073c --- /dev/null +++ b/learngit/zhangdongwei.txt @@ -0,0 +1 @@ +您讲的Git太好了,必须支持! diff --git a/learngit/zhangjia517_Rename.txt b/learngit/zhangjia517_Rename.txt new file mode 100644 index 0000000000..c41885994e --- /dev/null +++ b/learngit/zhangjia517_Rename.txt @@ -0,0 +1 @@ +测试下是否支持中文的文件名 谢谢廖老师! \ No newline at end of file diff --git a/learngit/zhanglintc.txt b/learngit/zhanglintc.txt new file mode 100644 index 0000000000..83cb548e83 --- /dev/null +++ b/learngit/zhanglintc.txt @@ -0,0 +1,3 @@ +一直想测试一些pull request功能,找不到我能够参与的项目。 +只好到这里来参与了。 +请一定要同意我的pull request啊! :D \ No newline at end of file diff --git a/learngit/zhangyan.txt b/learngit/zhangyan.txt new file mode 100644 index 0000000000..1f0d08b52a --- /dev/null +++ b/learngit/zhangyan.txt @@ -0,0 +1 @@ +Thank you for your tutorial,Michael! \ No newline at end of file diff --git a/learngit/zhaoxinyu.txt b/learngit/zhaoxinyu.txt new file mode 100644 index 0000000000..d9d8ec9ad0 --- /dev/null +++ b/learngit/zhaoxinyu.txt @@ -0,0 +1,3 @@ +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. diff --git a/learngit/zhouzhou.txt b/learngit/zhouzhou.txt new file mode 100644 index 0000000000..f206dc72ef --- /dev/null +++ b/learngit/zhouzhou.txt @@ -0,0 +1,2 @@ + +I'm a master student in ZJU.Thank you for your work very much. diff --git a/learngit/zhuqiao1018.txt b/learngit/zhuqiao1018.txt new file mode 100644 index 0000000000..df961a0b49 --- /dev/null +++ b/learngit/zhuqiao1018.txt @@ -0,0 +1 @@ +很好的git教程!感谢作者 \ No newline at end of file diff --git a/learngit/zk416605134@163.com.txt b/learngit/zk416605134@163.com.txt new file mode 100644 index 0000000000..087bf5b0ee --- /dev/null +++ b/learngit/zk416605134@163.com.txt @@ -0,0 +1 @@ +thank you sir for your help! \ No newline at end of file diff --git a/learngit/zongyl.txt b/learngit/zongyl.txt new file mode 100644 index 0000000000..e9baf1bcd2 --- /dev/null +++ b/learngit/zongyl.txt @@ -0,0 +1,97 @@ + + +hello,Mr Liao! Your tutorial is very good, So I learned quickly, Please receive my first pull request. thanks! +====================================================================== +git init 创建git仓库 + +git status 查看当前状态 + +git add 添加文件到缓冲区 + +git commit -m "..."提交 + +git diff 对比文件 + + +git log 命令显示从近到远的提交日志 + +git log --pretty=online 格式化 + +版本退回 +HEAD 表示当前版本 +HEAD^ 表示上一个版本 +HEAD^^ 表示上上个版本 +HEAD~n 表示上n个版本 + +git reset --hard HEAD^ + +git reset --hard 1111111 退回到指定的版本 1111111表示commit id + +git reflog 显示命令执行历史 + +git checkout -- 撤销工作区的修改。 + +git reset HEAD file 撤销已经add的修改。 + +删除文件 +rm 从本地删除文件 + +git -rm 删除版本库中的文件 + +远程仓库 + +关联远程仓库 git默认为origin +git remote add origin git@github.com:zongyl/learngit.git + +把当前分支master推送到远程。第一次推送远程,加上-u参数,可以将本地的master 和远程的master分支关联起来。 +以后的推送或者拉去可以简化命令。 +git push -u origin master + +git push origin master 提交到远程。 + +从远程克隆到本地 +git clone git@github.com:zongyl/learngit.git + +git支持多种协议,默认的git://使用shh,但也可以用https等其他协议。 git协议速度最快。 + +分支管理 + +git checkout -b dev --创建并切换到dev分支上 +-b 表示创建并切换,相当于以下两条命令 +git branch dev +git checkout dev + +git branch ---列出所有分支,带*号的为当前分支 + +git merge dev ---合并指定分支(dev)到当前分支。 + +git branch -d dev ---删除分支 + +git log --graph ---查看分支合并图。 + + +分支合并时,git默认使用fast forward模式。删除分支后,会丢掉分支信息,看不出做过合并。 + +git merge --no--ff dev 合并分支,禁用fast forward 模式。 + + + + + + + + + + + + + + + + + + + + + + diff --git a/learngit/zouyiran.txt b/learngit/zouyiran.txt new file mode 100644 index 0000000000..bbf86906a3 --- /dev/null +++ b/learngit/zouyiran.txt @@ -0,0 +1 @@ +I have a better understanding about git & github after I visit your website,thank you so much. \ No newline at end of file diff --git a/learngit/zpcandzhj.txt b/learngit/zpcandzhj.txt new file mode 100644 index 0000000000..855becf1f6 --- /dev/null +++ b/learngit/zpcandzhj.txt @@ -0,0 +1,6 @@ +老师的教程很不错! +我们学生缺少项目开发经验,老师要是能够结合一个案例细致地讲述一下企业项目开发 +到底是怎么进行版本控制的,大家怎么合作的,讲的稍微完整细致一点就锦上添花了! +O(∩_∩)O谢谢老师的教程!! + +鸟鹏 2014.11.19 \ No newline at end of file diff --git a/learngit/zxae86.txt b/learngit/zxae86.txt new file mode 100644 index 0000000000..595ec4854a --- /dev/null +++ b/learngit/zxae86.txt @@ -0,0 +1 @@ +谢谢 好人一生平安! \ No newline at end of file diff --git a/learngit/zzhblh.txt b/learngit/zzhblh.txt new file mode 100644 index 0000000000..1f0d08b52a --- /dev/null +++ b/learngit/zzhblh.txt @@ -0,0 +1 @@ +Thank you for your tutorial,Michael! \ No newline at end of file diff --git a/learngit/zzz.txt b/learngit/zzz.txt new file mode 100644 index 0000000000..1fb207d474 --- /dev/null +++ b/learngit/zzz.txt @@ -0,0 +1 @@ +I love ppppython \ No newline at end of file diff --git a/learngit140830.txt b/learngit140830.txt new file mode 100644 index 0000000000..d1843df52b --- /dev/null +++ b/learngit140830.txt @@ -0,0 +1,2 @@ +Thank you, Mr liao. +Your blog helped me a lot, I have already followed your sina weibo. diff --git a/learngit20150128.txt b/learngit20150128.txt new file mode 100644 index 0000000000..09bb273331 --- /dev/null +++ b/learngit20150128.txt @@ -0,0 +1 @@ +learn git form http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137628548491051ccfaef0ccb470894c858999603fedf000 \ No newline at end of file diff --git a/learngitbyffh.txt b/learngitbyffh.txt new file mode 100644 index 0000000000..e5b67eb2bc --- /dev/null +++ b/learngitbyffh.txt @@ -0,0 +1,3 @@ +Hello, liao: + +I am very happy to learn git. diff --git a/lecion.md b/lecion.md new file mode 100644 index 0000000000..46e4cc3877 --- /dev/null +++ b/lecion.md @@ -0,0 +1,117 @@ +##安装好git后,第一步配置: + git config --global user.name = "lecion" + git config --global user.email = "ylc931116@gmail.com" + +#初始化一个Repository + mkdir rep + cd rep + git init + +#add,commit + git add *** + git commit -m "***" + +#log + git log --pretty=oneline + git log --graph --pretty=online --abbrev-commit + git reflog + +#回到历史版本 + git reset --hard HEAD^ //HEAD表示当前版本,HEAD^ 上一个版本 HEAD^^ 上两个版本 HEAD~100 前100个版本 + +#diff 查看差异 + git diff *** + +#工作区(Working Directory) +>电脑里能看到的目录 (比如创建的learngit文件夹就是一个`工作区`) +#版本库(Repository) +>工作区有一个隐藏目录`.git`,这个不算工作区,而是Git版本库。Git的版本库里存了很多东西,最重要的称为`stage`的`暂存区`。git add 后的内容就是放在暂存区,直到被commit + +#撤销修改 + git checkout -- *** //把***在工作区的修改全部撤销 +* 没有git add,则恢复到和版本库一模一样 +* 如果git add,则恢复到缓存区的状态 + +#撤销缓存区(unstage) + git reset HEAD *** //把***的修改从缓存区移除 + +#删除文件 + rm test.txt + git rm test.txt + git commit -m "del test.txt" +>如果删错了,用git checkout -- test.txt 即可将版本库的test.txt恢复到工作区,无论是删除或是修改都可以采用此操作 + +#远程仓库 +* 使用Git,创建SSH Key + + ssh-keygen -t rsa -C "ylc931116@gmail.com" +* 登陆Github, 打开Account Settings, "SSH Keys"页面,填入 id_rsa.pub里的内容 +* Github上创建Repository `learngit` +* 将本地现有仓库和git关联 + + git remote add origin git@github.com:lecion/learngit.git + git push -u origin master + >因为是第一次提交,需要用`-u`,不但把本地master分支内容推送到远程新的master分支,还把本地的master分支和远程master分支关联起来,以后提交就可简化命令 +* 如果以后本地做了修改,就可以通过以下命令提交 + + git push orgin master + +#最好的方式 +>在远程建立一个Repository后,从远程clone + + git clone git@github.com:lecion/gitskills.git +#创建新分支 + git checkout -b dev +>`-b`表示创建并切换 + + git branch dev +>此种方式也可以 + +#查看分支 + git branch +>会列出所有分支,在当前分支前以`*`标注 + +#切换分支 + git checkout master +#合并分支 + git merge dev +#删除分支 + git branch -d dev + git branch -D dev +>`-D`强制删除没有合并的分支 + +#修复Bug + git stash +>暂存当前工作区,处理完bug后,回到该分支 + + git stash list +>查看暂存列表 + + git stash pop +>弹出最近的stash + + git stash apply + git stash drop + git stash apply@{0} + +#查看远程库 + git remote -v +>`-v`显示详细信息 + +#推送分支 + git push origin master + git push origin dev +* master分支是主分支,因此要时刻与远程同步; +* dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同 步; +* bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每 周到底修复了几个bug; +* feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + +#使用标签 + git tag v1.0 + git tag -a v0.9 -m "version 0.9 released" 234234 + git show v0.1 + git tag -d v1.0 + git push origin v1.0 + git push origin --tag + git push origin:refs/tags/v1.0 + diff --git a/leejore b/leejore new file mode 100644 index 0000000000..be8d704fe5 --- /dev/null +++ b/leejore @@ -0,0 +1 @@ +try fork and push.Thank U..... \ No newline at end of file diff --git a/leirenbaobao_UTF8.txt b/leirenbaobao_UTF8.txt new file mode 100644 index 0000000000..56c6560065 --- /dev/null +++ b/leirenbaobao_UTF8.txt @@ -0,0 +1,73 @@ +顶一下廖前辈 + +git init +git add xxx.txt +git commit xxx.txt + +git status +git diff + +git log +git log --pretty=oneline +HEAD表示当前版本, HEAD^上一个版本, HEAD^^ 上上版本 HEAD~100 +git reset +git reset --hard HEAD^ +git reset --hard 3628164(版本号) +git reflog + +工作区--add-》暂存区--commit-》master + +git记录的是对文件的修改 + +git checkout -- xxx.txt +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +git reset HEAD file + +git rm xxx.txt + +================== + +SSH加密 +ssh-keygen -t rsa -C "youremail@example.com" + +git remote add origin git@github.com:leirenbaobao/learngit.git +git push -u origin master +git push origin master + +git clone git@github.com:leirenbaobao/gitskills.git + +查看分支:git branch +创建分支:git branch +切换分支:git checkout +创建+切换分支:git checkout -b +合并某分支到当前分支:git merge +删除分支:git branch -d + +冲突修改 + +git merge --no-ff -m "merge with no-ff" ctrlz +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + +git stash +git stash list +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除;另一种方式是用git stash pop,恢复的同时把stash内容也删了 +git stash apply stash@{0} + + +git branch -D ctrlz在未完成合并的情况下 + +git remote/git remote -v + +git push origin master/git push origin ctrlz + +git tag /git tag v1.0 6224937/git tag + +命令git push origin 可以推送一个本地标签; +命令git push origin --tags可以推送全部未推送过的本地标签; +命令git tag -d 可以删除一个本地标签; +命令git push origin :refs/tags/可以删除一个远程标签。 + + diff --git a/leix101.txt b/leix101.txt new file mode 100644 index 0000000000..d2fd9646a3 --- /dev/null +++ b/leix101.txt @@ -0,0 +1 @@ +try pull request and thank you! \ No newline at end of file diff --git a/lgt945.txt b/lgt945.txt new file mode 100644 index 0000000000..9e9a73d6ed --- /dev/null +++ b/lgt945.txt @@ -0,0 +1,5 @@ +hi,michaelliao,thanks for your help about git. +初学git,发现的确是多人协作的好工具,刚开始觉得一个人学习不需要使用版本控制,但是发现其实早早的养成一个良好的学习习惯是好的开始,决定所有的过程都通过git记录下来。 +感谢Michael回复,开始以为只是没有merge我的文件,刚在邮箱里看到Michael的贴心回复,原来是我的文件没有用utf-8编码,这次再重新编码上传。。。 +anyway thanks +lgt945 \ No newline at end of file diff --git a/li-xinyang_note.md b/li-xinyang_note.md new file mode 100644 index 0000000000..1640e69945 --- /dev/null +++ b/li-xinyang_note.md @@ -0,0 +1,226 @@ +--- +BookTitle: Git-Tutorial +Author:lv +URL: http://lvwzhen.gitbooks.io/git-tutorial/ +--- + +# Git-Tutorial + +Git 为分布式版本控制系统(类似的有 Mercurial 和 Bazaar),它用于纪录文件修改详情。其他版本控制系统有 CVS(Concurrent Versions System)和 SVN (Apache Subversion) 均为集中式版本控制系统。集中式版本控制系统将版本库存放于中央服务器,需要联网且每次修改与提交均需要与服务器交换信息效率很低。分布式则使每一个使用者都拥有一个版本库(无中央服务器),这提高了效率和安全性。除此外 Git 还提供强大的分支管理。 + +**创建版本库** + +`$ git init` 将当前目录建为管理仓库。`.git` 文件来跟踪版本库。版本控制只可跟踪文本文件的改动,但无法追踪二进制变化(可知文件大小改变)。不同语言尽量使用统一编码 UTF-8 来支持全平台。 + +**文件入仓** + +首先将文件添加至仓库 `$ git add filename.txt` 然后将文件提交 `$ git commit -m "message"` (`-m` 为本次提交说明)。`commit` 可一次提交多个文件,所以可多次 `add` 不同文件,例如下面的例子。 + +``` +$ git add file1.txt +$ git add file2.txt +$ git add file3.txt +$ git commit -m "add 3 files" +``` + +**修改文本** + +`git status` 输出仓库当前状态。`git diff` 显示修改内容。 + +**版本回退** + +`git log` 查看历史纪录,其可用 `--pretty=oneline` 修改显示方式。16进制数组为版本号(Commit ID)和 SVN 不同,Git 版本号为 SHA1 计算所得(用自动递加会造成版本号冲突)。Git 使用 `HEAD` 表示当前版本,上一个版本为 `HEAD^`,再上一个为 `HEAD^^`,之后的为 `HEAD~100`(以100为例)。下面的代码返回特定版本: + +``` +$ git reset --hard HEAD^ +``` + +返回特点版本后,与其之后的所有提交均不会显示。只能使用版本号来进行之后版本的恢复操作,如下: + +``` +$ git reset --hard 3628164 +``` + +Git 内部使用 `HEAD` 指针来选当前版本。且 Git 提供 `$ git reflog` 记录每一次的命令。 + +**工作区和暂存区** + +工作区(Working Directory),版本库(Repository)中有暂存区(stage 或 index)还有第一个分支 master 以及指向它的指针 HEAD。将文件添加到版本库里分两步执行,第一步,将文件添加至暂存区,第二步,将暂存区文件提交至当前分支。既每次修改不添加暂存区将不会被添加至版本库。 + +**管理修改** + +Git 跟踪并管理*修改*,并非文件。 + +**撤销修改** + +`$ git checkout -- readme.md` 撤销全部 `readme.md` 在工作区的修改。这又分两种情况,第一种,文件并未存放至暂存区,撤销即返回和版本库相同状态。第二种,撤销返回至添加到暂存区时的状态。`--` 在此处极为重要,它在此区分撤销与创建新分支。用下面的代码将暂存区的文件回归至工作区: + +``` +$ git reset HEAD readme.md +# 放弃工作区修改 +$ git checkout -- readme.md +``` + +若修改版本已从暂存区提交至版本库,只可用版本回退的方法进行撤销,如若推送至远程库则无法撤销。文件只可恢复至当前版本库的最新版本,最近提交后的修改将丢失。 + +**删除文件** + +Git 中删除也属于修改操作。删除后的两种情况,第一种为确认删除用 `$ git rm test.txt` 将文件从工作区删除并将删除动作添加至暂存区。第二种为误删,可用 `$ git checkout -- test.txt` 恢复删除文件。 + +**远程仓库** + +GitHub 提供 Git 仓库托管,本地 Git 仓库与 GitHub 仓库间的传输通过 SSH 加密。第一步创建 SSH Key。如在用户目录下无 `.ssh` 目录,使用下面的代码创建即可: + +``` +$ ssh-keygen -t rsa -C "youremail@example.com" +``` + +在文件夹内,`id_rsa` 为私钥(Private Key),`id_rsa.pub` 为公钥(Public Key)。第二步,在 GitHub 添加 SSH Key,只需将公钥中内容粘贴至 Key 文本框即可。需要添加 SSH Key 的原因是确认身份,如有若干电脑仅需把每台设备的公钥添加即可。 + +**添加远程库** + +此时的 GitHub 仓库即可当备份也可支持多人协作。添加远程库,首先需在 GitHub 新建新库,创建后可从此仓库克隆新仓库也可使之与本地仓库相关联。关联本地仓库与远程仓库的方法: + +``` +$ git remote add origin git@github.com:username/repositoryname.git + +$ git push -u origin master +``` + +由于远程仓库为空,使用 `-u` 可推送并关联本地 master 与远程 master。在此之后的远程提交均可用 `$ git push origin master` 来完成。 + +**克隆远程库** + +`git clone` 在当前位置克隆一个本地库。当多人协作开发时,只需各自从远程服务器克隆即可。Git 支持多种协议,默认为 `git://`(速度最快)使用 SSH,但也可使用 https(速度慢且每次需要输入口令,适用于仅开放 https 端口的情况) 等其他协议。 + +**分支管理** + +在 Git 中分支的创建、切换以及删除都可以快速完成(无文件数量无关,仅为指针改变)。每一次提交 Git 都会将其串联成时间线,主线称之为*主分支*即 master 分支而 HEAD 指向的为当前分支。使用 `$ git checkout -b branchname` 创建新分支,`-b` 表示创建并切换,等同于下面的代码: + +``` +# 创建分支 +$ git branch dev +# 切换分支 +$ git checkout dev +``` + +`git branch` 用于查看当前分支,当前分支用 `*`表示。创建分支后即可在其中进行操作。操作完成后即可切换分支 `$ git checkout master`, `$ git merge dev` 合并指定分支与当前分支(Fast-forward,直接把 master 指向 dev 分支)。合并后即可删除不必要分支 `$ git branch -d dev`,因为分支操作非常便捷与迅速,所以 Git 鼓励使用分支进行任务并在完成后合并删除分支。其效果与 master 分支上工作相同但过程更安全。 + +**解决冲突** + +发生冲突后需手动解决再提交,`git status` 可以显示冲突文件。Git 用 `<<<<<<<`,`=======`,`>>>>>>>` 标记不同分支。使用带参数的 `git log` 也可查看分支合并情况: + +``` +$ git log --graph --pretty=oneline --abbrev-commit +# 查看分支合并图 +$ git log --graph +``` +**分支管理策略** + +Git 在使用 Fast-forward 时因为改变指针(无合并痕迹),删除分支后会丢失分支信息。强制禁用 Fast-forward 模式,Git 会在 merge 时进行新的 commit 这样可将分支历史查看分支信息。 + +``` +$ git merge --no-ff -m "merge with no-ff" dev +# no-ff 为禁用 Fast-forward +``` + +分支策略在开发时的几项原则,首先 master 分支最为稳定仅用于发布新版本,其次开发工作全部都应该在 dev 的分支上进行。 + +**Bug分支** + +因为 Git 中分支的强大,修复 Bug 也可使用新建临时分支的方法,修复后在合并并删除临时分支。 Git 提供 `stash` 来存储当前工作现场。 + +``` +# 查看以储存的工作区 +$ git stash list +# 恢复且不删除 stash 内容 +$ git stash apply +# 恢复指定 stash 内容(以0为例) +$ git stash apply stash@{0} +# 恢复并删除 stash 内容 +$ git stash pop +``` + +**Feature分支** + +使用 `$ git branch -D branchname` 删除未被 merge 的分支。开发新功能最好新建分支。 + +**多人协作** + +Git 自动对应本地及远程 master 分支,远程仓库默认名为 origin。 + +``` +# 查看远程仓库 +$ git remote +# 远程仓库详细信息 +$ git remote -v + +# 推送分支会推送到相应分支 +$ git push origin master +$ git push origin dev +``` + +master 为主分支需时刻于远程同步,dev 为团队工作分支也学时刻同步。 + +团队克隆(clone)默认只有 master 分支,如需其他分支则必须在本地创建远程 origin 的 dev 分支。 + +``` +$ git checkout -b dev origin/dev +``` + +使用 `git pull` 抓取最新版本,解决冲突本地合并后再次推送。多人协作流程为,首先 `git push origin branch-name` 推送修改,若失败则表示远程分支比本地更新需 `git pull` 合并。如有冲突,解决冲突后本地提交再推送,如显示 "no tracking information" 则表示本地分支与远程分支未创建链接关系,使用 `git branch --set-upstream branch-name origin/branch-name` 来创建。 + +**标签管理** + +标签为版本库快照,它为指向某个 commit 的指针(分支可移动,标签不可)。 + +创建标签可用 `git tag v1.0` 创建有说明的标签可用 `git tag -a v0.1 -m "version 1.0 release"`,查看可以 `git tag` 其顺序为字母顺序排列。为特点体检打标签可用 `git tag v1.1 6224937` 后跟 commit id 即可。查看标签信息可用 `git show v1.0` 可用查看文字说明。 + +删除标签可用 `git tag -d v0.1`。推送标签至远程 `git push origin v0.1` 或 `git push origin --tags` 推送全部本地标签。删除远程标签用如下代码: + +``` +# 先删除本地标签 +$ git tag -d v0.0 +# 删除远程标签 +$ git push origin :refs/tags/v0.0 +``` + +**忽略文件** + +GitHub [提供](https://github.com/github/gitignore)忽略文件配置文件。 + +**配置别名** + +``` +$ git config --global alias.st status +# st 设置等同于 status 更多例子如下 +$ git config --global alias.br branch +$ git config --global alias.co checkout + +# 很酷 log 显示 +$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" +``` + +**Git Cheatsheet** + +[Download](https://dl.dropboxusercontent.com/u/1725146/00_InfoHosting/tower_cheatsheet_grey_EN.pdf) + + + + + + + + + + + + + + + + + + + + diff --git a/libertyBoy b/libertyBoy new file mode 100644 index 0000000000..ae207ba066 --- /dev/null +++ b/libertyBoy @@ -0,0 +1 @@ +hello,libertyBoy diff --git a/liboLiao.txt b/liboLiao.txt new file mode 100644 index 0000000000..c554395504 --- /dev/null +++ b/liboLiao.txt @@ -0,0 +1,5 @@ +我是来和廖老师打招呼的. +我学习了你的教程,受益匪浅,多谢这莫大功无私的做法. +你应该在CZ任过教吧?^_^ +我也是姓廖的,fork一下也是来认个同姓亲戚。 +总之,多谢你的git教程,教会了一批又一批啥都不懂只会蛮横懵懂的小毛孩。^_^ \ No newline at end of file diff --git a/lidc.txt b/lidc.txt new file mode 100644 index 0000000000..964675ac06 --- /dev/null +++ b/lidc.txt @@ -0,0 +1 @@ +感谢廖大师让我学会了基本的git相关知识,再次感谢! diff --git a/lifelong.txt b/lifelong.txt new file mode 100644 index 0000000000..9266bb1cad --- /dev/null +++ b/lifelong.txt @@ -0,0 +1 @@ +谢谢廖老师!!!^.^ \ No newline at end of file diff --git a/lihuacan.txt b/lihuacan.txt new file mode 100644 index 0000000000..10c7833d17 --- /dev/null +++ b/lihuacan.txt @@ -0,0 +1,3 @@ +I read your blogs. +I want to try. +Thank you! \ No newline at end of file diff --git a/lijunyu.txt b/lijunyu.txt new file mode 100644 index 0000000000..16910a5f02 --- /dev/null +++ b/lijunyu.txt @@ -0,0 +1 @@ +额,真的会上瘾,感觉自己病了,病的不轻,头一次有这么强烈的主动学习的愿望,我怎么了!!!!都是你害的!!! \ No newline at end of file diff --git a/likeban.txt b/likeban.txt new file mode 100644 index 0000000000..caab7c6986 --- /dev/null +++ b/likeban.txt @@ -0,0 +1,3 @@ +Thank you so much for your work on Python and Git for me, one freshman. +Absolutely, these are best choices for me to start Python and git. +Again, thank you so sincerely! diff --git a/lintaian-github-pullrequest-test.txt b/lintaian-github-pullrequest-test.txt new file mode 100644 index 0000000000..f39ded7095 --- /dev/null +++ b/lintaian-github-pullrequest-test.txt @@ -0,0 +1 @@ +hehe,pass or not pass,I don`t care! diff --git a/linzhenan.txt b/linzhenan.txt new file mode 100644 index 0000000000..61fb7a20d8 --- /dev/null +++ b/linzhenan.txt @@ -0,0 +1,3 @@ +Git is much different from SVN and Visual Studio Online. +I believe it will be my friend when I set out for Linux from Windows. +Thank you for this useful tutorial. \ No newline at end of file diff --git a/lipsummeow.txt b/lipsummeow.txt new file mode 100644 index 0000000000..6f732c73e1 --- /dev/null +++ b/lipsummeow.txt @@ -0,0 +1,3 @@ +Thousand thanks for writting such a wonderful, short and yet to the point tutorial:) +Way better than the "Pro Git" written by ... sorry don't even remember the author's name, threw the printout into the recycle bin when i found your blog:) +Total respect in your great work! I also read the Python tutorial:) diff --git a/lir6206.txt b/lir6206.txt new file mode 100644 index 0000000000..c0bcfb9fc2 --- /dev/null +++ b/lir6206.txt @@ -0,0 +1 @@ +thank you! \ No newline at end of file diff --git a/lishuailibertine b/lishuailibertine new file mode 100644 index 0000000000..2d73f3a91e --- /dev/null +++ b/lishuailibertine @@ -0,0 +1 @@ +哎呦嘿 diff --git a/littledou_learngit.txt b/littledou_learngit.txt new file mode 100644 index 0000000000..03bbbc5107 --- /dev/null +++ b/littledou_learngit.txt @@ -0,0 +1,118 @@ +# git_use +创建版本库-- +$ mkdir learngit +$ cd learngit +$ pwd +/Users/michael/learngit + + + git init--创建git仓库 + + git add readme.txt--用命令git add告诉Git,把文件添加到仓库: + + git commit -m "wrote a readme file"--用命令git commit告诉Git,把文件提交到仓库 + + git status--当前版本库状态.git status命令可以让我们时刻掌握仓库当前的状态 + + git diff readme.txt--顾名思义就是查看difference,显示的格式正是Unix通用的diff格式 + + git log--查看log日志, + + git log --pretty=oneline--日志转成一行,比较醒目 + + git reset --hard HEAD^--回退一个版本 + + git reset --hard 3628164--回退到版本3628164 + + cat readme.txt--看看readme.txt的内容 + + git reflog--Git提供了一个命令git reflog用来记录你的每一次命令 + + + 第一步是用git add把文件添加进去,实际上就是把文件修改添加到暂存区; + + 第二步是用git commit提交更改,实际上就是把暂存区的所有内容提交到当前分支。 + + git checkout -- readme.txt--把readme.txt文件在工作区的修改全部撤销,这里有两种情况: + +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; + +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 + +总之,就是让这个文件回到最近一次git commit或git add时的状态 + + git reset HEAD readme.txt--git reset命令既可以回退版本,也可以把暂存区的修改回退到工作区 + + 要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; + + 关联后,使用命令git push -u origin master第一次推送master分支的所有内容;此后,每次本地提交后, + 只要有必要,就可以使用命令git push origin master推送最新修改; + + git clone git@github.com:littledou/git_use.git--克隆版本库 + + git branch --查看分支 + + git branch dev --创建分支dev + + git checkout dev--切换到分支dev + + git checkout -b dev--创建dev分支并切换到dev + + git merge dev --合并dev分支到当前分支 + + git branch -d dev-- 删除分支dev + + +# 解决冲突 + + 分支dev修改了README.md,切换到主分支也去修改README.md,这样冲突无法直接merge,先 git merge dev,然后查看文件详情中出现的《《《HEAD,调整修改之后在master上提交 + + git merge --no-ff -m "merge with no-ff" dev--强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息 + +# Bug解决 + + 当前在dev分支需要去master解决1bug + + git stash 把当前工作现场“储藏”起来,等以后恢复现场后继续工作:切到master chackout一个issue分支,解决bug合并到master删除issue切到dev + + git stash list--查看当前保存的工作区 + + git stash apply--恢复保存的工作区 + + git stash drop-- 删除stash + + git stash pop--恢复并删除 + + +#强制删除某未合并的功能分支 + + git branch -D feature + +# 多人协作 + + git remote--查看远程库的信息 + + git remote -v --查看更详细的信息 + + +#标签管理 + + git tag v1.0--创建v1.0表签 + + git tag --查看标签 + + git tag v1.0 6224234--对某次提交打标签 + + git show v1.0--标签信息 + + git tag -d v1.0--删除标签 + + git push origin --tags--将全部未提交的标签提交到远程 + + 已提交的标签删除 + + git tag -d v1.0->git push origin :refs/tags/v1.0 + + + + \ No newline at end of file diff --git a/liudonglei.txt b/liudonglei.txt new file mode 100644 index 0000000000..3d9ab2d885 --- /dev/null +++ b/liudonglei.txt @@ -0,0 +1,14 @@ + 现在是北京时间2015年7月26日星期日,晚上。 +正值暑假,实验室楼下在装修,老师出差了,同学有些放假回家了,我一个人静静地独拥这个开着 +空调22度的实验室,专心看着廖sir的git教程,久违的hack感觉又回来了,我想我本质上还是一个IT技术人。 + 我已经使用过svn有一年多了,用它管理实验室的代码,在各自快速的开发试错的过程中, +冲突是不可避免的,而且你负责的部分的代码有些依赖别人的功能, +在这种工作模式下的一个烦人的地方就是,你必须等待依赖的人提交一个正常的代码后, +你的部分才能运行,更有甚者,有人没有规范的开发意识,提交一个error百出无法运行的 +版本,回去睡觉了。233 + 久闻git和github的大名,安装git也有半年了,但是一直没怎么用过,git与svn有些基础概念是 +一样的,所以我看这个教程是重点看stage和分支这2个概念,这2个概念讲的很清楚,图文并茂,让我理解了不少。 +github也注册了一个账号,也star和fork了几个repo,但是也从没做过修改,自然也无从请求pull request了。 + 看来,还是要参与到这些开源社区里面。 + 最后,感谢廖sir的git教程! + diff --git a/liuiuii.txt b/liuiuii.txt new file mode 100644 index 0000000000..5db0025125 --- /dev/null +++ b/liuiuii.txt @@ -0,0 +1 @@ +hello ,thank you! \ No newline at end of file diff --git a/liuluheng_learngit.txt b/liuluheng_learngit.txt new file mode 100644 index 0000000000..8a03523b06 --- /dev/null +++ b/liuluheng_learngit.txt @@ -0,0 +1,2 @@ +git has many things to learn, +not so easy to grasp....:(..:). diff --git a/liuxiaokun b/liuxiaokun new file mode 100644 index 0000000000..dcb64ddf92 --- /dev/null +++ b/liuxiaokun @@ -0,0 +1 @@ +test how to send a pull request! diff --git a/liuxu0315.txt b/liuxu0315.txt new file mode 100644 index 0000000000..caf4829607 --- /dev/null +++ b/liuxu0315.txt @@ -0,0 +1,199 @@ +廖雪峰的官方网站: + www.liaoxuefeng.com + +Git教程总结: +--------------------------------------------------------------------------------------------------------- +git-----| + |----安装git----| + | |--Ubuntu--| + | | 安装git: + | | $ sudo apt-get install git + | | 配置git: + | | $ git config --global user.name "Your Name" + | | $ git config --global user.email "email@example.com" + | + | + |--创建版本库---| + | |--创建本地git工作目录--| + | | $ mkdir git + | | $ cd git + | | $ git init + | | + | |--第一次提交到本地git库--| + | | $ vim liuxu0315.txt + | | $ git add liuxu0315.txt + | | $ git commit -m "add liuxu0315.txt" + | + | + |--时光机穿梭---| + | |-------| + | | 查看当前状态: + | | $ git status + | | 查看difference: + | | $ git diff + | | + | |--版本退回--| + | |-------查看提交历史记录: + | | $ git log + | | $ git log --pretty=oneline + | |-------退回上一个版本: + | | $ git reset --hard HEAD^ + | | 退回上上一个版本: + | | $ git reset --hard HEAD^^ + | | 退回往上100个版本: + | | $ git reset --hard HEAD~100 + | |-------从上一版本回到当前版本: + | | 查看历史命令: + | | $ git relog + | | (得到当前版本commid id:3628164) + | | 返回到当前版本: + | | $ git reset --hard 3628164 + | | + | |--撤销修改--| + | |-------修改文件: + | | $ vim liuxu0315.txt + | | (噢,改错了,要返回修改前) + | | 撤销修改: + | | $ git checkout -- liuxu0315.txt + | |-------再次修改: + | | $ vim liuxu0315.txt + | | $ git add liuxu0315.txt + | | (完蛋了,又修改错了) + | | 取消此次add: + | | $ git reset HEAD liuxu0315.txt + | | 撤销修改: + | | $ git checkout -- liuxu0315.txt + | | + | |--删除文件--| + | | $ rm liuxu0315.txt + | | $ git rm liuxu0315.txt + | | $ git commit -m "rm liuxu0315.txt" + | + | + |---远程仓库----| + | |--创建设置SSH Key--| + | | 1.创建SSH Key: + | | $ ssh-keygen -t rsa -C "youremail@example.com" + | | 2.将~/.ssh/id_rsa.pub复制到github的"个人设置-->SSH Keys"处。 + | | + | |--添加远程库--| + | | 1.在github中先添加好一个仓库。 + | | (得到一个如:git@github.com:liuxu0315/helloworld.git 这样地址) + | | (liuxu0315则是你的github ID) + | | 2.在本地仓库下运行: + | | $ git remote add origin git@github.com:liuxu0315/helloworld.git + | | 此时可以推送到远程github仓库了: + | | $ git push -u origin master + | | (参数 -u 是将本地master分支和远程master分支关联起来) + | | + | |--克隆远程仓库--| + | | $ git clone git@github.com:michaelliao/learngit.git + | + | + |---远程分支----| + | |--创建与合并分支--| + | |-------创建并跳转到dev分支: + | | $ git checkout -b dev + | | (git checkout为跳转到分支,-b为新建分支) + | |-------创建dev分支: + | | $ git branch dev + | | 跳转到dev分支: + | | $ git checkout dev + | |-------查看分支: + | | $ git branch + | | + | |-------然后在dev分支上工作: + | | $ vim dev.txt + | | $ git add dev.txt + | | $ git commit -m "add dev.txt" + | |-------回到master合并dev分支: + | | $ git checkout master + | | $ git merge dev + | |-------删除dev分支: + | | $ git branch -d dev + | | + | |--解决冲突--| + | | (当在dev和master同时修改dev.txt文件后,) + | | (在master中合并dev分支是会冲突) + | | (此时需要编辑一下dev.txt解决掉冲突,) + | | (然后再add , commit提交) + | | + | |--工作区暂存--| + | | (用于:需要跳转到其他分支,) + | | ( 又不想commit当前分支,) + | | ( 也不想放弃当前修改时) + | | + | |-------保存当前工作现场: + | | $ git stash + | | (跳转到其他分支工作后再回来此分支) + | |-------恢复工作现场: + | | 1.查看以保存的stash内容: + | | $ git stash list + | | (可以看到0个或多个stash@{n},n=1,2,3,4...) + | | 2.恢复工作现场: + | | $ git stash apply + | | (或者) + | | $ git stash apply stash@{0} + | | 3.删除stash内容: + | | $ git stash drop + | |---------------直接恢复并删除stash内容: + | | $ git stash pop + | + | + |---标签管理----| + | |--创建标签--| + | |-------快速创建标签:(例:$ git tag ) + | | $ git tag v1.0 + | | 查看标签: + | | $ git tag + | | 给以前的commit id为6224937打标签: + | | $ git tag v0.9 6224937 + | | 查看标签详细信息: + | | $ git show v0.9 + | |-------创建带说明的标签(commit为3628164): + | | $ git tag -a v0.1 -m "version 1.0" 3628164 + | | 创建带GPG密钥的标签(确定本地已经配置和GPG KEY): + | | $ git tag -s v0.2 -m "signed version 0.2 released" fec145a + | | + | |--操作标签--| + | |-------删除本地某个标签: + | | $ git tag -d v0.1 + | | 推送某个标签到远程仓库: + | | $ git push origin v1.0 + | | 一次全部推送未推送的本地标签: + | | $ git push origin --tags + | |-------删除远程仓库标签: + | | $ git tag -d v0.9 + | | $ git push origin :refs/tags/v0.9 + | + | + |---自定义Git---| + | |--忽略特殊文件--| + | | 1.将忽略的文件写入.gitignore中 + | | $ vim .gitignore + | | (如:) + | | (dev.txt) + | | (*.class) + | | (temp/) + | | 2.提交.gitignore到git仓库 + | | $ git add .gitignore + | | $ git commit -m "add .gitigonre" + | | + | |--配置别名--| + | | $ git config --global alias.st status + | | $ git st + | | $ git config --global alias.co checkout + | | $ git config --global alias.ci commit + | | $ git config --global alias.br branch + | | $ git config --global alias.unstage 'reset HEAD' + | | $ git config --global alias.last 'log -l' + | | $ git config --llobal alias.lg "log --color --graph + | | --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset + | | %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" + | | $ git lg + | | + | | (以上配置放在 .git/config 中,) + | | (个人配置文件在 ~/.gitconfig 中) + + + diff --git a/liye71023326.txt b/liye71023326.txt new file mode 100644 index 0000000000..6b71494ed2 --- /dev/null +++ b/liye71023326.txt @@ -0,0 +1 @@ +今天一天按照教程实际操作了各条命令,收益很大,非常感谢。 diff --git a/liyingzh.txt b/liyingzh.txt new file mode 100644 index 0000000000..91f78fd01c --- /dev/null +++ b/liyingzh.txt @@ -0,0 +1,47 @@ +1 初始化一个Git仓库,使用git init命令。 + +2 添加文件到Git仓库,分两步: + 第一步,使用命令git add ,注意,可反复多次使用,添加多个文件; + 第二步,使用命令git commit,完成。 + +3 要随时掌握工作区的状态,使用git status命令。 + +4 如果git status告诉你有文件被修改过,用git diff可以查看修改内容。 + +5 HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 + +6 穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 + +7 要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。 + +8 Git跟踪修改,每次修改,git add再git commit. 如果不add到暂存区,那就不会加入到commit中。 + +9 撤销修改 + 场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 + 场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 + +10 + 查看分支:git branch + 创建分支:git branch + 切换分支:git checkout + 创建+切换分支:git checkout -b + 合并某分支到当前分支:git merge + 删除分支:git branch -d + 用git log --graph命令可以看到分支合并图。 + 要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 +11 + 查看远程库信息,使用git remote -v; + 本地新建的分支如果不推送到远程,对其他人就是不可见的; + 从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + 在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + 建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + 从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 +12 + 命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; + git tag -a -m "blablabla..."可以指定标签信息; + 命令git tag可以查看所有标签。 + 命令git push origin 可以推送一个本地标签; + 命令git push origin --tags可以推送全部未推送过的本地标签; + 命令git tag -d 可以删除一个本地标签; + 命令git push origin :refs/tags/可以删除一个远程标签。 +13 Fork A Repo:https://help.github.com/articles/fork-a-repo/ diff --git a/lnddStrong.txt b/lnddStrong.txt new file mode 100644 index 0000000000..90a685ebe5 --- /dev/null +++ b/lnddStrong.txt @@ -0,0 +1 @@ +thank you very much! \ No newline at end of file diff --git a/loveuqian.txt b/loveuqian.txt new file mode 100644 index 0000000000..47c788b03b --- /dev/null +++ b/loveuqian.txt @@ -0,0 +1 @@ +thanks for your git course diff --git a/lucien.txt b/lucien.txt new file mode 100644 index 0000000000..9f4c7831f2 --- /dev/null +++ b/lucien.txt @@ -0,0 +1 @@ +Thx for your course! diff --git a/luckyflower.txt b/luckyflower.txt new file mode 100644 index 0000000000..858fb926e1 --- /dev/null +++ b/luckyflower.txt @@ -0,0 +1,44 @@ +git init 初始化一个Git仓库 +git add 文件添加到仓库(实际上就是把文件修改添加到暂存区;) +git commit -m "xx" 把文件提交到仓库(实际上就是把暂存区的所有内容提交到当前分支) +git status 仓库当前的状态 +git diff 查看修改内容 +git log 查看从最近到最远的提交日志(嫌输出信息太多,可以加上 ?--pretty=oneline 参数) +HEAD 指当前版本(上一个版本就是HEAD^,上上一个版本就是HEAD^^,100个版本可写成HEAD~100) +git reset --hard commit_id 在版本的历史之间穿梭 +git reflog 查看命令历史,可重返未来的版本 +git diff HEAD -- 查看工作区和版本库里面最新版本的区别 +git checkout -- file 丢弃工作区的修改(若未git add到暂存区,直接丢弃工作区的修改) +git reset HEAD file 把暂存区的修改撤销掉,重新放回工作区(已经git add到了暂存区,先撤销放回工作区,再执行丢弃工作区修改的命令) +git rm 删除一个文件 +git remote add origin git@server-name:path/repo-name.git 将本地仓库与远程库关联起来 +git clone git@server-name:path/repo-name.git 将远程库克隆到本地 +git push -u origin master 第一次推送master分支的所有内容; +git push origin master 把当前分支master推送到远程 +git branch 查看分支 +git branch 创建分支 +git checkout 切换分支 +git checkout -b 创建+切换分支 +git merge 合并某分支到当前分支(启用Fast forward模式,删除分支后,会丢掉分支信息) +git merge --no-ff 合并某分支到当前分支(启用普通模式,合并后的历史有分支,能看出来曾经做过合并) +git branch -d 删除分支 +git log --graph 查看分支合并图 +git stash 当前工作现场“储藏”起来,等以后恢复现场后继续工作 +git stash list 查看被‘储藏’的工作现场 +git stash apply 恢复被‘储藏’的工作现场 +git stash drop 删除被‘储藏’的工作现场 +git stash pop 恢复+删除被‘储藏’的工作现场 +git branch -D 强行删除丢弃一个没有被合并过的分支 +git remote 查看远程库的信息 +git remote -v 显示远程库更详细的信息 +git push origin branch-name 推送分支,就是把该分支上的所有本地提交推送到远程库。 +git checkout -b branch-name origin/branch-name 在本地创建和远程分支对应的分支 +git branch --set-upstream branch-name origin/branch-name 指定本地分支与远程分支的链接(链接关系没有创建会提示“no tracking information”) +git pull 把最新的提交从远程库origin抓下来 +git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; +git tag 查看所有标签 +git show 查看标签信息 +git push origin 推送一个本地标签 +git push origin --tags 推送全部未推送过的本地标签 +git tag -d 删除一个本地标签 +git push origin :refs/tags/ 删除一个远程标签 \ No newline at end of file diff --git a/lwzhang.txt b/lwzhang.txt new file mode 100644 index 0000000000..88a66e2a5d --- /dev/null +++ b/lwzhang.txt @@ -0,0 +1 @@ +非常棒的教程!非常感谢! \ No newline at end of file diff --git a/lynntalk.txt b/lynntalk.txt new file mode 100644 index 0000000000..31ce1b7053 --- /dev/null +++ b/lynntalk.txt @@ -0,0 +1,3 @@ +thanks for your article. +i have learnt more about git. +your website is briliant. diff --git a/lzm.test b/lzm.test new file mode 100644 index 0000000000..021a8aa680 --- /dev/null +++ b/lzm.test @@ -0,0 +1,2 @@ +hello +push test diff --git a/m-yo.txt b/m-yo.txt new file mode 100644 index 0000000000..2d3189098a --- /dev/null +++ b/m-yo.txt @@ -0,0 +1,10 @@ +This is my first time to learn git. +Thank you so much for your blog course. +It is very easy to understand for beginners like me. +A new world is open to me now after taking this course. +Thank you!! +誠にありがとうございました! + +Best Regards, +yuman + diff --git a/manythanks.txt b/manythanks.txt new file mode 100644 index 0000000000..384283dfd1 --- /dev/null +++ b/manythanks.txt @@ -0,0 +1,7 @@ +many thanks for your effort to make git easy for us to learn it well . +Actually, I used to have some konwledge about git , as it's really a powerfull tool for porgrammer, and make up my mind to leran it well. +but ,I did not find a suitable tutrial... so I qiut ..finaly..OOOO + +your tutrial benefits me a lot .. + +thanks ! diff --git a/mark442.txt b/mark442.txt new file mode 100644 index 0000000000..57cf9e8e95 --- /dev/null +++ b/mark442.txt @@ -0,0 +1 @@ +git教程非常详细,对于初学者非常有益,感谢分享. \ No newline at end of file diff --git a/markdown_log.md b/markdown_log.md new file mode 100644 index 0000000000..78257733e6 --- /dev/null +++ b/markdown_log.md @@ -0,0 +1,163 @@ +t是什么? + +- Git是`分布式版本控制系统`。而集中式的版本控制系统不但速度慢,而且必须联网才能使用。 +- 2008年,GitHub网站上线(程序员社区网站,这网站上可以托管自己的网站库,基于Git完成的) + +> ###Git的作用 + +- 备份文件 +- 记录历史 +- 回到过去 +- 多端共享 +- 团队协作 + +> ###Git的诞生 + +Linus创建了Linux(1991年),由于很多人提交代码,都是最后都是通过手工方式合并的(1991年-2002年)。最后很多人都有意见,于是Linus选择了(2002年)一个商业的版本控制系统BitKeeper,但是开发Samba的Andrew`试图破解`BitKeeper的协议(2005年4月),于是BitMover公司怒了,要收回Linux社区的免费使用权。于是Linus花了两周时间自己用C写了一个`分布式版本控制系统`,这就是Git!(2005年4月初发布) + +> ###分布式和集中式的区别 + +- 集中式版本控制系统最大的毛病就是必须联网才能工作,如果`网速慢`就很悲剧、如果不联网就没有办法提交,查看记录。 +- 分布式版本控制系统根本没有“中央服务器”,每个人的电脑上都是一个完整的版本库,就不需要联网了 +- 你的同事也在他的电脑上改了文件A,这时,你们俩之间只需把各自的修改推送给对方,就可以互相看到对方的修改了。 +- 分布式版本控制系统的安全性要高很多,因为每个人电脑里都有完整的版本库,某一个人的电脑坏掉了不要紧 +- 而集中式版本控制系统的中央服务器要是出了问题,所有人都没法干活了。 +- Git极其强大的分支管理 + +在实际使用分布式版本控制系统的时候,其实很少在两人之间的电脑上推送版本库的修改,因为可能你们俩不在一个局域网内,两台电脑互相访问不了,也可能今天你的同事病了,他的电脑压根没有开机。因此,分布式版本控制系统通常也有一台充当“中央服务器”的电脑,但这个服务器的作用仅仅是用来方便“交换”大家的修改,没有它大家也一样干活,只是交换修改不方便而已。 + +> ###安装完成后(安装过程自行查阅),设置用户名和密码 + +``` +$ git config --global user.name "Your Name" +$ git config --global user.email "email@example.com" +``` +注意`git config`命令的`--global`参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。 + +如果要查看全局参数就输入 `git config --global --list` +查看Git版本`git --version` + + +--- + + +> ###创建版本库 + +1. 进入某个目录 +2. 使用 `git init`把这个目录变成版本库,这时目录下会多出一个.git的隐藏目录,千万不要修改这个目录的东西,所有Git的记录都在里面 + +> ###把文件添加到版本库 + +1. 先修改一个文件a.php +2. 使用`git add a.php`(把这个文件添加到暂存区) +3. 使用`git commit -m '增加了xxx函数'`(把文件提交到当前分支) + +每当你觉得文件修改到一定程度的时候,就可以“保存一个快照”,这个快照在Git中被称为commit。一旦你把文件改乱了,或者误删了文件,还可以从最近的一个`commit`恢复 + +> ###状态查看 + +- `git status`查看当前状态 +- `git diff a.php` 查看没有add的a.php和已add的a.php的区别(如果文件已经add到暂存区则diff无法查看) + +> ###版本退回 + +在退回到某个commit快照版本之前,我们必须要知道那个版本的ID号 + +在Git中,用`HEAD`表示当前版本,也就是最新的提交`3628164...882e1e0`,上一个版本就是`HEAD^`,上上一个版本就是`HEAD^^`,当然往上100个版本写100个^比较容易数不过来,所以写成`HEAD~100` + +- 如果我们commit(快照、提交到当前分支)很多次文件,那么肯定记不住哪次提交修改了哪些内容,这时候就可以通过`git log`命令来查看(倒序显示,最新的修改在最前面),如果嫌输出的信息太多,我们可以使用`git log --pretty=oneline`来简洁查看,输出的一大串字符串是`commit id`也就是`版本号` +- 既然我们知道了版本号,那么如何退回到指定的版本呢?我们可以通过`git reset --hard 3628164`命令来退回到指定的版本(注意:这里的`--hard`的意思是版本号`指针`),版本号没必要写全,前几位就可以了,Git会自动去找。当然也不能只写前一两位,因为Git可能会找到多个版本号,就无法确定是哪一个了。`OK,我们现在已经可以回到过去!` +- 既然我们回到了过去,但是又后悔了,想回到原来的地方,但是,这时候使用`git log`发现,这时候已经看不到未来的版本号了,当前的版本号是最新的!那么这样就意味着,找不到未来的版本号了?找不到未来的版本号也就意味着回不去了!那么怎么办呢?Git提供了一个命令`git reflog`用来记录你的每一次命令,也就是说:你可以通过`git reflog`命令找到未来的版本号,用于回到未来! + +``` +也就是说 + +现在有3个版本 + +版本号:333 + +版本号:222 + +版本号:111 + +我现在用git reset —hard 222 退回到222版本, + +git log 后 就看不到333版本了 + +必须要用git relog才能看到222之前的333版本号 + +然后在通过git reset —hard 333 恢复到333 + +``` + + + +> ###撤销修改 + +我在文件a.php添加了一行“我的傻逼老板任然喜欢SVN”。突然发现,如果这么写本老板看见了,就完蛋啦。 + +这时候查看`git status` 说明可以用`git checkout -- a.php`来放弃工作区修改。 + + + +``` + +这里有两种情况: +一种是a.php自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是a.php已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +总之,就是让这个文件回到最近一次git commit或git add时的状态。 +``` + +如果你已经把不该说的话添加到了暂存区,那么查看`git status` 说明可以用`git reset HEAD file`可以把暂存区的修改撤销掉(unstage),重新放回工作区 + +如果已经提交了,则只能用版本退回! + + + +> ###删除文件 + + + +我现在添加一了个conf.php文件,但是写完这个文件并提交commit后,发现不需要了,就把它在工作区删掉。这时候版本库的文件和工作区的文件就不一样了(工作区多了一个conf.php文件,而版本库还没删掉),那么就要把它从版本库删掉,用:`git rm conf.php`,并且把这一次的删除,提交到版本库,这样工作区和版本库就一致了。 + +如果还没有commit之前(但是已经提交到暂存区),发现,这时候我又需要这个文件了怎么办呢?那么就要用:`git reset HEAD `(从暂存区恢复)在用`git checkout -- `(用版本库里的版本替换工作区的版本)恢复 + + + +> ###创建、合并分支 + + + +1. 创建debug分支`git branch debug`在切换到debug分支`git checkout debug` ,也可以一句话简写`git checkout -b debug`,-b参数表示创建并切换 + +2. 用`git branch`查看当前分支,命令会列出所有分支,当前分支前面会标一个*号 + +3. 修改当前分支文件,并commit + +4. 在切换到master分支:`git checkout master`,这时候,查看debug分支修改的内容,是查不到的,因为不是在当前的master分支下修改的,那么我们就要合并分支 + +5. 合并分支:`git merge debug` 注意!!!这里合并分支方式是`Fast forward`模式,但这种模式下,`删除分支后,会丢掉分支信息!`我们要禁用这`Fast forward`模式,加上`--no-ff`参数就可以用`普通模式`合并,合并后的历史有分支,能看出来曾经做过合并,而`fast forward`合并就看不出来曾经做过合并。必须要用:`git merge --no-ff -m "merge with no-ff" debug` 这样来合并分支,因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 + +6. 合并完成后,我们就可以删掉debug分支了:`git branch -d debug` + +7. 然后我们在查看分支`git branch`,debug分支果然被删除了 + +8. 用`git log --graph --pretty=oneline`分支合并图 + + + +> ###修复BUG的stash + +- 如果你正在dev分支干活,这时候接到一个紧急修复BUG的任务,但是你的dev分支工作只进行到一半,还没法提交,幸好,Git还提供了一个`git stash`功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作。 + +- 用`git stash list`命令查看储存的工作区,一是用`git stash apply`恢复,但是恢复后,stash内容并不删除,你需要用`git stash drop`来删除; 另一种方式是用`git stash pop`,恢复的同时把stash内容也删了: + + + + + + + + + + diff --git a/marvin-git-marvincreat.txt b/marvin-git-marvincreat.txt new file mode 100644 index 0000000000..67410b56f3 --- /dev/null +++ b/marvin-git-marvincreat.txt @@ -0,0 +1,3 @@ +thank you! +very easy to understand +best wishes to you and hope you write more tutorials. diff --git a/maxfong.txt b/maxfong.txt new file mode 100644 index 0000000000..ebb0000c2a --- /dev/null +++ b/maxfong.txt @@ -0,0 +1,31 @@ +ssh-keygen -t rsa -C "youremail@example.com” +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; + +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改 + +查看分支:git branch +创建分支:git branch name +切换分支:git checkout name +创建+切换分支:git checkout -b name +合并某分支到当前分支:git merge name +删除分支:git branch -d name + + + +暂存:git stash +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +$ git stash list$ git stash apply stash@{0} + +查看远程库信息,使用git remote -v; + +本地新建的分支如果不推送到远程,对其他人就是不可见的; + +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 \ No newline at end of file diff --git a/me.txt b/me.txt new file mode 100644 index 0000000000..f2aa86d258 --- /dev/null +++ b/me.txt @@ -0,0 +1 @@ +hello diff --git a/mecup.txt b/mecup.txt new file mode 100644 index 0000000000..0bc2ea4dbd --- /dev/null +++ b/mecup.txt @@ -0,0 +1,7 @@ +very good + +thank you very much for your best git lesson! + + mecup + 2015.4.10 + diff --git a/mengtianwxs.txt b/mengtianwxs.txt new file mode 100644 index 0000000000..da778e5b41 --- /dev/null +++ b/mengtianwxs.txt @@ -0,0 +1,3 @@ +"hello Mr Liao, +thank you! you are good man ! +" \ No newline at end of file diff --git a/mintyminty.txt b/mintyminty.txt new file mode 100644 index 0000000000..9c42f7b4b2 --- /dev/null +++ b/mintyminty.txt @@ -0,0 +1,3 @@ +just spent this afternoon playing with git, thanks Michael for the awesome tutorial! :DD + +Greetings from Canada ;-) diff --git a/mj.txt b/mj.txt new file mode 100644 index 0000000000..00fc4c3e80 --- /dev/null +++ b/mj.txt @@ -0,0 +1 @@ +111111111111111 \ No newline at end of file diff --git a/mls.txt b/mls.txt new file mode 100644 index 0000000000..2706ab3827 --- /dev/null +++ b/mls.txt @@ -0,0 +1 @@ +多谢 \ No newline at end of file diff --git a/more-github-id.txt b/more-github-id.txt new file mode 100644 index 0000000000..770f77e3bb --- /dev/null +++ b/more-github-id.txt @@ -0,0 +1 @@ +this is my push. \ No newline at end of file diff --git a/mrhopelee.txt b/mrhopelee.txt new file mode 100644 index 0000000000..1960915356 --- /dev/null +++ b/mrhopelee.txt @@ -0,0 +1 @@ +I was a rookie, but I will try my best \ No newline at end of file diff --git a/muyunlei@gmail.txt b/muyunlei@gmail.txt new file mode 100644 index 0000000000..c67354c1c0 --- /dev/null +++ b/muyunlei@gmail.txt @@ -0,0 +1,2 @@ +谢谢带来这么通俗易懂的Git教程! +Thx so much! diff --git a/my-git-linxiaolong.txt b/my-git-linxiaolong.txt new file mode 100644 index 0000000000..21b405d8c2 --- /dev/null +++ b/my-git-linxiaolong.txt @@ -0,0 +1 @@ +import os diff --git a/my-github-1.txt b/my-github-1.txt new file mode 100644 index 0000000000..73b450fa47 --- /dev/null +++ b/my-github-1.txt @@ -0,0 +1,3 @@ +Mr. Liao , +Thank you very much for teaching Git. +2015-03-02 diff --git a/my-github-ZiYangLqm.txt b/my-github-ZiYangLqm.txt new file mode 100644 index 0000000000..6f573ca585 --- /dev/null +++ b/my-github-ZiYangLqm.txt @@ -0,0 +1 @@ +非常感谢! \ No newline at end of file diff --git a/my-github-id.txt b/my-github-id.txt new file mode 100644 index 0000000000..b54c66f9f1 --- /dev/null +++ b/my-github-id.txt @@ -0,0 +1 @@ +test pull diff --git a/my-github-lxx723.txt b/my-github-lxx723.txt new file mode 100644 index 0000000000..02b107c212 --- /dev/null +++ b/my-github-lxx723.txt @@ -0,0 +1,2 @@ +thank you so much +git is so great diff --git a/my-github-pull-test.txt b/my-github-pull-test.txt new file mode 100644 index 0000000000..40e85cca35 --- /dev/null +++ b/my-github-pull-test.txt @@ -0,0 +1 @@ +Git very good! \ No newline at end of file diff --git a/my-github-susan.txt b/my-github-susan.txt new file mode 100644 index 0000000000..7cf3929ac9 --- /dev/null +++ b/my-github-susan.txt @@ -0,0 +1,4 @@ +读了你的这篇GitHub教程,才真正的在头脑中对GitHub有了一个清晰的概念。 +否则在以前,总是以为GitHub很神秘。 +现在只是感觉Git好伟大,linus好伟大,如你一样的程序员也好伟大。 +我也要努力! \ No newline at end of file diff --git a/my-github-wk.txt b/my-github-wk.txt new file mode 100644 index 0000000000..a1209cb690 --- /dev/null +++ b/my-github-wk.txt @@ -0,0 +1,6 @@ +thank you, a good session +赞一个,非常好的教程! +能否增加一些关于GIT挂钩的教程以及merge和rebase区别,谢谢! + +老师有没有解决乱码的好方法呢,谢谢!windows下面,不知道如何解决,谢谢! + diff --git a/my-learn-git b/my-learn-git new file mode 100644 index 0000000000..37b670186b --- /dev/null +++ b/my-learn-git @@ -0,0 +1,3 @@ +your lesson helps me a lot +thank you~ +sorry to not donate any money diff --git a/my_git.txt b/my_git.txt new file mode 100644 index 0000000000..c4c51911a4 --- /dev/null +++ b/my_git.txt @@ -0,0 +1 @@ +my first git log diff --git a/mytest.txt b/mytest.txt new file mode 100644 index 0000000000..a5cb291d11 --- /dev/null +++ b/mytest.txt @@ -0,0 +1,2 @@ +That's my first GitHut ID to pull the change. +Thank you. diff --git a/mzds.txt b/mzds.txt new file mode 100644 index 0000000000..e3e9bd8e33 --- /dev/null +++ b/mzds.txt @@ -0,0 +1 @@ +看了您的文章受益匪浅,感谢您的教程! \ No newline at end of file diff --git a/netwenk.txt b/netwenk.txt new file mode 100644 index 0000000000..1feaff8b9b --- /dev/null +++ b/netwenk.txt @@ -0,0 +1 @@ +thanks! diff --git a/netxiaosheng.txt b/netxiaosheng.txt new file mode 100644 index 0000000000..ecdc0e37be --- /dev/null +++ b/netxiaosheng.txt @@ -0,0 +1,5 @@ + Hi,Brother! + I am a junior student in NEPU + I study this course just one day + + Thank you ! \ No newline at end of file diff --git a/nickboyst-github-id.txt b/nickboyst-github-id.txt new file mode 100644 index 0000000000..9b7c4ea5dc --- /dev/null +++ b/nickboyst-github-id.txt @@ -0,0 +1,3 @@ +I am a new one for git, i am so lucky that i have read your paper. +I learned a lot and i will follow your courses. +Thank you so much ! diff --git a/niniliwei.txt b/niniliwei.txt new file mode 100644 index 0000000000..ea4963674d --- /dev/null +++ b/niniliwei.txt @@ -0,0 +1 @@ +Hello,Liao!Understand git deeper every time I come back to your tutorial,thanks. diff --git a/niniliwei_new.txt b/niniliwei_new.txt new file mode 100644 index 0000000000..76b1b7bd62 --- /dev/null +++ b/niniliwei_new.txt @@ -0,0 +1 @@ +我又回来学习了,再学一遍感觉就是不一样。 diff --git a/niyeqing.txt b/niyeqing.txt new file mode 100644 index 0000000000..dcae08c4d2 --- /dev/null +++ b/niyeqing.txt @@ -0,0 +1 @@ +作为一个纯自学者,PRO GIT虽好,但容易看晕,而且缺少实践。很感谢廖雪峰的这个教程,step by step,踏实而又不枯燥。好教程,赞一个! 前面确实是用Notepad++ UTF8打开,误选了应用于打开ANSI文件所致。 diff --git a/nobsu.txt b/nobsu.txt new file mode 100644 index 0000000000..1a0b90a813 --- /dev/null +++ b/nobsu.txt @@ -0,0 +1,2 @@ +今年大四,刚刚参加完校招,之前一直打算在github上面放一些自己的case,决定学习git,发现博主的教程,,连续三小时,我真的学会了git!!!!!!!!!!非常感谢 嗤嗤嗤 + diff --git a/note b/note new file mode 100644 index 0000000000..a753cd1ca9 --- /dev/null +++ b/note @@ -0,0 +1 @@ +谢谢你的教程哈 ! diff --git a/nsp.txt b/nsp.txt new file mode 100644 index 0000000000..b083e60a04 --- /dev/null +++ b/nsp.txt @@ -0,0 +1,3 @@ +my name is nsp, + +nsp is short for No Sucn Person:D \ No newline at end of file diff --git a/openhardnudd.txt b/openhardnudd.txt new file mode 100644 index 0000000000..b9217f7530 --- /dev/null +++ b/openhardnudd.txt @@ -0,0 +1,2 @@ +Learning your Git tutorial,I can use the Git. +thank you ,Mr liao. \ No newline at end of file diff --git a/outstanding-heart.txt b/outstanding-heart.txt new file mode 100644 index 0000000000..dd4758ae32 --- /dev/null +++ b/outstanding-heart.txt @@ -0,0 +1 @@ +Thank you ! ^_^ diff --git a/oxbambooxo.txt b/oxbambooxo.txt new file mode 100644 index 0000000000..ea7e690d45 Binary files /dev/null and b/oxbambooxo.txt differ diff --git a/oxyzine b/oxyzine new file mode 100644 index 0000000000..ac0bb8aff0 --- /dev/null +++ b/oxyzine @@ -0,0 +1,3 @@ +学习git +教程首推廖雪峰 +搜狗输入法能直接打出这个名字 diff --git a/p1usJ4de.txt b/p1usJ4de.txt new file mode 100644 index 0000000000..3b066b6194 --- /dev/null +++ b/p1usJ4de.txt @@ -0,0 +1 @@ +Thank you... diff --git a/pangbo.txt b/pangbo.txt new file mode 100644 index 0000000000..12b3dda56d --- /dev/null +++ b/pangbo.txt @@ -0,0 +1 @@ +感谢廖雪峰,只用3个小时就让我学会了git,非常棒的教程! \ No newline at end of file diff --git a/pangjiawei19.txt b/pangjiawei19.txt new file mode 100644 index 0000000000..8e6fa4f3de --- /dev/null +++ b/pangjiawei19.txt @@ -0,0 +1 @@ +今天完整学习了git的教程,对这个东西有了初步认识,以后尝试把自己的东西管理到这里,继续努力 diff --git a/panpanxu.txt b/panpanxu.txt new file mode 100644 index 0000000000..df347113a1 --- /dev/null +++ b/panpanxu.txt @@ -0,0 +1 @@ +git通过设计减少网络通信和磁盘IO,所以在切换等操作时速度快。 diff --git a/paul2011.txt b/paul2011.txt new file mode 100644 index 0000000000..b12d51ceab --- /dev/null +++ b/paul2011.txt @@ -0,0 +1,3 @@ +hey,master Liao: + I just learn GIT from your wiki quckly and simplely!thanks for your share. now I start to learn Python ,so I will read your wiki for Python soon and expectantly! +may the GOD bless you! diff --git a/pclimbing.txt b/pclimbing.txt new file mode 100644 index 0000000000..72da71d192 --- /dev/null +++ b/pclimbing.txt @@ -0,0 +1,5 @@ +希望亲爱的michaelliao在心情好的时候看到这个~O(∩_∩)O +git教程对我很有帮助, + +祝你健康快乐! + diff --git a/pfjhetg.html b/pfjhetg.html new file mode 100644 index 0000000000..05ea632e93 --- /dev/null +++ b/pfjhetg.html @@ -0,0 +1,162 @@ + + + Evernote Export + + + + + + +
+ +
+
  1. 把当前这目录变成git可以管理的仓库
    $ git init
  2. 把文件添加到仓库
    $ git add filename
  3. git 仓库的状态
    $ git status
  4. 把文件提交到仓库
    $ git commit -m "wrote a readme file"
    +[master (root-commit) cb926e7] wrote a readme file
    + 1 file changed, 2 insertions(+)
    + create mode 100644 readme.txt
    +-m 后面是本次的提交说明
  5. 查看文件修改内容
    $ git diff readme.txt 
    +diff --git a/readme.txt b/readme.txt
    +index 46d49bf..9247db6 100644
    +--- a/readme.txt
    ++++ b/readme.txt
    +@@ -1,2 +1,2 @@
    +-Git is a version control system.
    ++Git is a distributed version control system.
    + Git is free software.
    +查看工作区和版本库里面最新版本的区别(HEAD指向当前的分支)
    $ git diff HEAD -- readme.txt 
    +diff --git a/readme.txt b/readme.txt
    +index 76d770f..a9c5755 100644
    +--- a/readme.txt
    ++++ b/readme.txt
    +@@ -1,4 +1,4 @@
    + Git is a distributed version control system.
    + Git is free software distributed under the GPL.
    + Git has a mutable index called stage.
    +-Git tracks changes.
    ++Git tracks changes of files.
  6. 查看提交历史(只有commit)
    $ git log
    只显示版本号和提交注视
    $ git log --pretty=oneline
    +3628164fb26d48395383f8f31179f24e0882e1e0 append GPL
    +ea34578d5496d7dd233c827ed32a8cd576c5ee85 add distributed
    +cb926e7ea50ad11b8f9e909c05226233bf755030 wrote a readme file
    +查看命令历史(包含reset,commit等)
    $ git reflog
  7. 在 git 中,当前版本用 HEAD 表示,上一个版本是 HEAD^ ,上上个版本是 HEAD^^,也可以用HEAD~+index,上10个版本可以写成 HEAD~10。
  8. 回到上一个版本
    $ git reset --hard HEAD^
    +根据版本号(3628164)回到此版本
    $ git reset --hard 3628164
  9. 查看工作区与版本库里面的文件区别
    $ git diff HEAD -- readme.txt 
    +diff --git a/readme.txt b/readme.txt
    +index 76d770f..a9c5755 100644
    +--- a/readme.txt
    ++++ b/readme.txt
    +@@ -1,4 +1,4 @@
    + Git is a distributed version control system.
    + Git is free software distributed under the GPL.
    + Git has a mutable index called stage.
    +-Git tracks changes.
    ++Git tracks changes of files.
  10. 把文件在工作区的修改全部撤销(git checkout -- file命令中的--很重要,没有--,就变成了“创建一个新分支”的命令)
    $ git checkout -- filename
    +如果文件修改后,还没有放到暂存区,撤销后,和版本的一样
    +如果文件已经放到暂存区,撤销户,回到暂存区的状态
  11. 把暂存区的文件撤销掉,重新放回工作区
    $ git reset HEAD readme.txt
    +请对照第8条git reset -- hard命令来进行区分
  12. 删除版本库里面的文件(包含再次 commit) +
    $ git rm test.txt
    +rm 'test.txt'
    +$ git commit -m "remove test.txt"
    +[master d17efd8] remove test.txt
    + 1 file changed, 1 deletion(-)
    + delete mode 100644 test.txt
  13. 生成 ssh key
    $ ssh-keygen -t rsa -C "youremail@example.com"
    +一路默认(不要密码)
    +/Users/js/.ssh  里面保存了生成的 key .pub 是公钥
  14. 添加远程仓库
    +首先在 git 新建一个仓库(git init),把这个仓库与本地仓库关联
    $ git remote add origin git@github.com:michaelliao/learngit.git
    +第一次把本地仓库的所有内容推送到远程库
    $ git push -u origin master
    +以后每次提交
    $ git push origin master
  15. SSH 警告(当你第一次使用Git的clone或者push命令连接GitHub时,会得到一个警告)
    The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
    +RSA key fingerprint is xx.xx.xx.xx.xx.
    +Are you sure you want to continue connecting (yes/no)?
    +这是因为Git使用SSH连接,而SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入yes回车即可
    +Git会输出一个警告,告诉你已经把GitHub的Key添加到本机的一个信任列表里了
    Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
    +这个警告只会出现一次,后面的操作就不会有任何警告了
  16. 从远程仓库克隆
    $ git clone git@github.com:pfjhetg/gitskills.git
    +Cloning into 'gitskills'...
    +remote: Counting objects: 3, done.
    +remote: Total 3 (delta 0), reused 0 (delta 0)
    +Receiving objects: 100% (3/3), done.
    +
    +$ cd gitskills
    +$ ls
    +README.md
  17. 创建分支并且切换
    $ git checkout -b dev
    +Switched to a new branch 'dev'
    +-b 表示创建并且切换
    +等于下面两条命令
    $ git branch dev(创建)
    +$ git checkout dev(切换)
    +Switched to branch 'dev'
  18. 查看当前分支
    $ git branch
    +* dev
    +  master
  19. 合并指定分支(dev)到当前分支上
    $ git merge dev
    +Updating d17efd8..fec145a
    +Fast-forward
    + readme.txt |    1 +
    + 1 file changed, 1 insertion(+)
    +注意到上面的Fast-forward信息,Git告诉我们,这次合并是“快进模式”,也就是直接把master指向dev的当前提交,所以合并速度非常快,这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并
    $ git merge --no-ff -m "merge with no-ff" dev
    +Merge made by the 'recursive' strategy.
    + readme.txt |    1 +
    + 1 file changed, 1 insertion(+)
    +因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去
  20. 删除指定(feature1)分支 -d表示删除
    $ git branch -d feature1
  21. 查看分支合并情况
    $ git log --graph --pretty=oneline --abbrev-commit
    +*   59bc1cb conflict fixed
    +|\
    +| * 75a857c AND simple
    +* | 400b400 & simple
    +|/
    +* fec145a branch test
    +...
  22. bug 分支
    +当你接到一个修复一个代号101的bug的任务时,很自然地,你想创建一个分支issue-101来修复它,但是,等等,当前正在dev上进行的工作还没有提交:
    +将当前工作区储存起来,等恢复以后继续工作
    $ git stash
    +Saved working directory and index state WIP on dev: 6224937 add merge
    +HEAD is now at 6224937 add merge
    +查看以前的工作现场
    $ git stash list
    +stash@{0}: WIP on dev: 6224937 add merge
    +将存储起来的内容恢复(同时从list中删除)
    $ git stash pop
    +# On branch dev
    +# Changes to be committed:
    +#   (use "git reset HEAD <file>..." to unstage)
    +#
    +#       new file:   hello.py
    +#
    +# 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:   readme.txt
    +#
    +Dropped refs/stash@{0} (f624f8e5f082f2df2bed8a4e09c12fd2943bdd40)
    将存储起来的内容恢复(从list中读取,不删除)
    $ git stash apply stash@{0}
    +将存储起来的内容删除(从list中删除)
    $ git stash apply dropstash@{0}
  23. 强行删除分支
    $ git branch -D feature-vulcan
    +如果要丢弃一个没有被合并过的分支,可以通过git branch -D <name>强行删除。
  24. 查看远程分支的信息
    $ git remote -v
    +origin  git@github.com:michaelliao/learngit.git (fetch)
    +origin  git@github.com:michaelliao/learngit.git (push)
    -v 显示更详细的信息
  25. 打一个新的标签
    $ git tag v1.0
  26. 查看所有标签
    $ git tag
    +v1.0
  27. 根据某个提交id ,打新的标签
    $ git tag v0.9 6224937
  28. 查看标签信息
    $ git show v0.9
    +commit 622493706ab447b6bb37e4e2a2f276a20fed2ab4
    +Author: Michael Liao <askxuefeng@gmail.com>
    +Date:   Thu Aug 22 11:22:08 2013 +0800
    +
    +    add merge
    +...
  29. 创建带说明的标签
    $ git tag -a v0.1 -m "version 0.1 released" 3628164
    +-a 标签名
    +-m 说明
    +还可以通过-s用私钥签名一个标签
    $ git tag -s v0.2 -m "signed version 0.2 released" fec145
  30. 删除标签
    $ git tag -d v0.1
    +Deleted tag 'v0.1' (was e078af9)
  31. 推送单个标签到远程服务器
    $ git push origin v1.0
    +Total 0 (delta 0), reused 0 (delta 0)
    +To git@github.com:michaelliao/learngit.git
    + * [new tag]         v1.0 -> v1.0
    推送本地所有未推送的标签
    $ git push origin --tags
    +Counting objects: 1, done.
    +Writing objects: 100% (1/1), 554 bytes, done.
    +Total 1 (delta 0), reused 0 (delta 0)
    +To git@github.com:michaelliao/learngit.git
    + * [new tag]         v0.2 -> v0.2
    + * [new tag]         v0.9 -> v0.9
  32. 删除远程服务器上面的标签
    +先从删除本地标签
    $ git tag -d v0.9
    +Deleted tag 'v0.9' (was 6224937)
    +然后删除远程上的标签
    $ git push origin :refs/tags/v0.9
    +To git@github.com:michaelliao/learngit.git
    + - [deleted]         v0.9

  33. 创建SSH Key,在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,打开Shell,创建SSH Key
    $ ssh-keygen -t rsa -C "youremail@example.com"
    +注意:ssh和后面的"-"之间没有空格。
  34. https格式
    https://github.com/pfjhetg/learngit.git
    +git格式 +
    git@github.com:michaelliao/learngit.git
  35. Git本地库和远程库关联时候,需要保证本地主分支要commit进去了一个文件(库不能为空),否者无法提交上去并且提示
    +error: src refspec master does not match any.
    +error: failed to push some refs to 'git@github.com:pfjhetg/learngit.git'
  36. 工作区(Working Directory):就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工作区
  37. 版本库(Repository):工作区有一个隐藏目录.git,这个不算工作区,而是Git的版本库
  38. Git的版本库里存了很多东西,其中最重要的就是称为stage(或者叫index)的暂存区,还有Git为我们自动创建的第一个分支master,以及指向master的一个指针叫HEAD
  39. git中的当前分支泛指当前所在的分区
    +js@JS-PC ~/git/learngit (master)这里的master就是表示在主分区
  40. 从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交
  41. 在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致
  42. 建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name
  43. 从远程抓取分支,使用git pull,如果有冲突,要先处理冲突

+
\ No newline at end of file diff --git a/pinefantasy.txt b/pinefantasy.txt new file mode 100644 index 0000000000..7d38006134 --- /dev/null +++ b/pinefantasy.txt @@ -0,0 +1,9 @@ +To: +Michaelliao + +Thank you very much. +Your Git Course is Good. +A very Good Job for me. + +From: +A Java Engineer, pinefantasy diff --git a/piterator.txt b/piterator.txt new file mode 100644 index 0000000000..b903dc8f6f --- /dev/null +++ b/piterator.txt @@ -0,0 +1 @@ +thank you, teacher liao diff --git a/pq1949-leartgit-for-3q.txt b/pq1949-leartgit-for-3q.txt new file mode 100644 index 0000000000..c0bcfb9fc2 --- /dev/null +++ b/pq1949-leartgit-for-3q.txt @@ -0,0 +1 @@ +thank you! \ No newline at end of file diff --git a/pull-request-from-changsure.txt b/pull-request-from-changsure.txt new file mode 100644 index 0000000000..cd310726b1 --- /dev/null +++ b/pull-request-from-changsure.txt @@ -0,0 +1,3 @@ +It's really awesome here. + From changsure + diff --git a/pullrequest test b/pullrequest test new file mode 100644 index 0000000000..3c7526c74d --- /dev/null +++ b/pullrequest test @@ -0,0 +1 @@ +want to do a test for pullrequest diff --git a/pullrequest.txt b/pullrequest.txt new file mode 100644 index 0000000000..082626df32 --- /dev/null +++ b/pullrequest.txt @@ -0,0 +1 @@ +just for demostrate pull request \ No newline at end of file diff --git a/pxtj.txt b/pxtj.txt new file mode 100644 index 0000000000..6ae6aaa3c5 --- /dev/null +++ b/pxtj.txt @@ -0,0 +1,139 @@ +1.初始化仓库:git init +2. 往仓库中添加文件: + git add //将文件修改添加到暂存区 + git commit -m "文件说明" //将暂存区中的所有内容提交到当前分支 + +3. 查看仓库状态:git status +4. 比较文件的不同,或者查看文件修改的地方: + git diff + +5. 版本回退 + 查看历史记录:git log + 查看最近的某次的记录:git log -<数字> //查看最近的指定某次的记录 + 查看精简的历史记录:git log --pretty=oneline + 查看输入命令的记录:git reflog + 版本表示:当前版本表示为HEAD,上一个版本表示为HEAD^,上上个版本表示为HEAD^^ + 上100个版本可以表示为HEAD~100 + 版本回退:git reset --hard <版本id> 举例:git reset --hard HEAD^ //表示返回到上一个版本; + +6. 查看某一文件的内容:Linux命令,如 cat ,more等; +7. Git的工作区和暂存区 + (1)工作区(Working Direction):所编辑的文件所在的目录; + (2)版本库(Repository):工作区文件夹中的.git文件夹; + 方式:git add 将文件修改信息从工作区添加到暂存区; + git commit -m "说明" 将暂存区的信息添加到分支; +8. Git跟踪的文件的修改而不是文件本身:每次修改如果不add到暂存区,那么当commit提交时就不会添加到分支中。 +9. 撤销修改: + 命令:git checkout -- <文件名> 如:git checkout -- readme.txt + (1)当文件自修改后还没有被add到暂存区,则撤销修改就会使文件回到与版本库分支中的文件一模一样; + (2)当文件已经add到暂存区,又作了修改,则插销修改就会回到与暂存区中的文件一样; + 注:此命令中的 -- 一定要有,如果没有 -- 就变成创建一个新的分支; + + 当修改已经add到暂存区,此时想要撤销修改时,就需要先将暂存区的修改回退到工作区,然后再工作区撤销修改; + 命令:git reset HEAD <文件名> + git checkout -- <文件名> + 如:git reset HEAD readme.txt + git checkout -- readme.txt + + 当已经提交到版本库,想撤销修改时,就需要进行版本回退。 +10. 删除文件: + (1)若文件已经提交到版本库,从版本库中删除文件:git rm <文件名> + (2)若文件添加到暂存区,从暂存区中删除文件:git rm -f <文件名> + (3)若在工作区删除了文件,但文件已添加到暂存区或者提交到版本库中,在工作区中恢复文件:git checkout -- <文件名> +11. 创建SSH Key:ssh-keygen -t rsa -C "youremail@example.com" + 生成.ssh文件,其中id_rsa为私钥,id_rsa.pub为公钥。 + 将id_rsa.pub中的公钥添加到gitHub.com中。 +12. 将工程合并到github.com上:在github上创建项目,然后根据提示绑定; + 首先,关联一个远程库: + git remote add origin http://github.com/Username/Projectname.git 或者 //此处的origin为一个别名,可以取其他名字。 + git remote add origin git@github.com:path/repo-name.git + 然后,推送到远程库中:git push -u origin master //第一次推送master中的所有内容; + 此后,若本地版本修改之后,只需要通过git push origin master命令就可以合并到github.com中。 +13. 将仓库项目克隆到本地:git clone git@github.com:path/repo-name.git +14. 创建分支 + (1)创建分支:git checkout -b <分支名称> + 其中,参数-b相当于两条命令:创建并切换:git branch <分支名称>,git checkout <分支名称>; + 如:git checkout -b dev + 可以在创建本地分支的同时,将远程分支的内容克隆(clone)到此分支:git checkout -b <本地分支名> <远程库名称>/<远程分支名称>,如: + git checkout -b dev origin/dev //创建本地分支dev的同时,将远程origin库中的dev分支克隆到本地dev分支中。 + (2)查看当前分支:git branch //列出所有分支,并在当前分支前显示一个*; + (3)分支切换:git checkout <分支名称>// + (4)分支合并:git merge <分支名称> //将指定分支合并到当前分支上 + (5)删除分支:git branch -d <分支名称> //删除指定分支//删除本地分支; + (6)删除远程分支:git push origin :<分支名称>//删除远程服务器上的分支,:代表删除分支; +15. 当Git无法合并时,需要先手动解决冲突,然后再提交,在合并; + 查看分支合并图命令:git log --graph //多行显示提交记录 + 或者 git log --graph --pretty=oneline //单行显示合并及提交记录,但会显示每个记录id的全称 + 或者 git log --graph --pretty=oneline --abbrev-commit //单行显示,每个记录的Id只会显示一部分; +16. 分支管理 + 通常通过命令:git merge <分支名称>合并时,如果可能(比如没有冲突),Git会用Fast Forward模式,此种模式下,合并完成后,会丢失分支信息; + 可以通过禁用Fast Forward模式,Git就会在merge时生成一个新的commit,这样就可以从分支历史记录中看到分支信息; + 禁用Fast Forward模式的关键字为--no-ff,完整命令: + git merge --no-ff -m "说明" <分支名称> //因为要生成一个新的commit,所以用-m添加说明; +17. 分支策略 + 在实际开发中,应该按照以下几个原则进行分支管理: + (1)master分支应该是非常稳定的版本,也就是用来发布新版本,通常不在此分支开发; + (2)在dev分支上开发,将每个人的成果合并到dev上,然后通过dev合并到master上进行发布; + (3)每个人都有自己的分支,比如John,Sam等等,在自己的分支上开发,之后将其合并到dev分支上。 +18. bug分支 + (1)修复bug时通常在master中建一个临时分支,修复完成后,合并分支,然后将临时分支删除; +19. 任务现场“储存”操作 + 当工作进行到一半,需要立即处理其他事务,则可以通过任务现场“储存”操作将正在进行的工作暂时隐藏起来。 + 命令关键字为:stash + (1)git stash:备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区的内容保存到Git栈中。 + (2)git stash pop:显示Git栈内的所有备份,恢复工作区的相关内容。由于可能存在多个stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复; + (3)git stash list:显示Git栈内所有备份,可以利用这个列表来决定从哪个地方恢复; + (4)git stash clear:清空Git栈。此时使用gitg等图形化工具会发现,原来stash的那些节点都会消失。 + (5)git stash apply stash@{<标号>}:恢复Git栈中第<标号>所代表的内容;此命令不会从Git栈中删除此条存储信息。 + 若要删除,需要用git stash drop命令。 +20. feature分支: + 每添加一个功能,最好针对此功能新建一个分支,在分支上开发完成之后,在进行合并; + 如果未合并时需要删除,则可以通过 git branch -D <分支名称> 强制删除; +21. 多人协作 + (1)查看远程库名称:git remote 或者 git remote -v //可以显示更加详细的信息 + git branch -a//查看本地和远程分支; + (2)推送分支:git push origin <分支名称> //此命令默认将当前分支推送到远程的master上:如:git push origin master + 若要将本地master分支推送到远程的dev(远程已建立此分支),需要指定远程分支的名称,因为本地master分支默认指向origin master分支:git push origin master:<远程分支名称>,如:git push origin master:dev + 本地除master分支,推送到远程分支时,直接使用git push origin <远程分支名> 即可。 + (3)抓取分支:git pull + 当有人对远程分支中的某一文件做了修改,并已完成推送,本地也对此文件做了修改,再推送时会推送失败。需要先将远程库中的文件pull(拉取)到本地, + 然后在本地合并并解决冲突,再往远程推送。 + git pull作用:取回远程主机某个分支的更新,在与本地的指定分支合并; + 命令格式:git pull <远程主机名> <远程分支名>:<本地分支名> + 如:git pull origin next:master //取回远程origin主机的next分支,与本地的master分支合并 + 当远程分支与当前分支合并,冒号后面的部分可以省略; + git pull先取回,在合并,相当于先git fetch,再做git merge: + (4)建立跟踪关系 + Git可以自动在本地分支与远程分支之间,建立一种跟踪关系(tracking)。比如,在git cmaster分支lone时,所有本地分支默认与远程主机的同名分支,建立跟踪关系,也就是说,本地的master分支自动“追踪”origin/master分支。 + Git也可以手动建立跟踪关系:git branch --set-upstream <本地分支名> <远程主机名>/<远程分支名> + 如:git branch --set-upstream master origin/dev //指定本地master分支跟踪origin/dev分支。 + 如果当前分支与远程分支存在追踪关系,git pull就可以省略远程分支名称:git pull origin + 如果当前分支只有一个追踪分支,连远程主机名都可以省略:git pull //当前分支自动与唯一一个追踪分支合并; + 如果合并采用rebase模式,可以使用-rebase选项: + git pull --rebase <远程主机名> <远程分支名>:<本地分支名> + +22. 创建标签: + (1)创建命令:git tag ,如:git tag v1.0 + 查看所有标签:git tag + 注:默认标签是创建在最新提交的commit上的,需要早前的 commit打标签时,可用用commit的ID来打标签:git tag + (2)标签不是按照实际顺序列出而是按照字母排序。 + git show //查看标签信息; + (3)可以创建带有说明的标签,用-a指定标签名,-m指定说明文字。 + 如:git tag -a v0.1 -m "version 0.1 realeased" + 通过-s用私钥签名一个标签,如: + git tag -s v0.2 -m "signed version 0.2" + +23. 操作标签 + (1)删除标签:git tag -d ; + (2)创建的标签存储在本地,不会自动推送到远程,要将某个标签推送到远程,可以使用命令:git push origin + 一次性推送所有标签:git push origin --tags + (3)删除远程标签: + 先删除本地标签; + 然后通过命令:git push origin :refs/tags/ +24. 忽略特殊文件:https://github.com/github/gitignore + +25. 设置别名:git config --global alias.<别名> <命令名称> + 如:git config --global alias.st status //将status设置为st + +26. 配置文件: + (1)--global:针对当前用户起作用;如果不加,只针对当前的仓库起作用。 diff --git a/qcwdy.txt b/qcwdy.txt new file mode 100644 index 0000000000..a3f22d518d --- /dev/null +++ b/qcwdy.txt @@ -0,0 +1 @@ +Thanks for your git blog! diff --git a/qcypggs@qq.com b/qcypggs@qq.com new file mode 100644 index 0000000000..933afcc3fa --- /dev/null +++ b/qcypggs@qq.com @@ -0,0 +1,2 @@ +Hi: + 你好,我是case,很高兴给你发这个消息,来验证我的学习所得,我在百度python,找到你的教程,然后又看git教程,这是我们见过的最好的git教程,没有之一。您的博客:提供原创中文精品教程,果然做到了,而且是精华级别,第一次想给开源作者赞助的。好了马屁拍完,再次感谢。 diff --git a/qidafang.txt b/qidafang.txt new file mode 100644 index 0000000000..da348f4aab --- /dev/null +++ b/qidafang.txt @@ -0,0 +1 @@ +thanks! \ No newline at end of file diff --git a/rafael.txt b/rafael.txt new file mode 100644 index 0000000000..c609407533 --- /dev/null +++ b/rafael.txt @@ -0,0 +1,92 @@ +Thanks you! + +$git init + 在指定目录下创建git仓库 repository +$git add readme.txt + 添加文件或者是提交修改到 stage(暂存区) +$git commit -m “commit changes" + 提交stage中的内容到本地版本库 +$git status + 查看rep的当前状态,包括工作区与暂存区 +$git diff + 查看工作区与仓库间的区别,如果工作区文件已添加到暂存区stage中,则忽略diff +$git log + 查看版本控制历史记录 +$git log —pretty=oneline + 单行显示历史记录 +$git reflog + 查看所有操作历史记录,包括回退记录 +$git reset —hard HEAD^ + 回退工作区上个版本 +$git reset —hard defiaw3io(版本 id) + 回退到指定版本id对应版本 +$git checkout — readme.txt + 丢弃工作区的修改(未提交到暂存区stage的修改) +$git reset HEAD readme.txt + 丢弃暂存区的修改unstage,重新放回工作区 + 区别与版本回退 git reset —hard HEAD^ +$git rm readme.txt + 删除文件,commit后生效 +$git checkout — readme.txt + 还未提交rm的情况下,可以撤销删除,恢复工作区文件 + +$git remote add origin “git site" + 把本地仓库与远程库相关联,origin就是远程库的名字,git默认,可修改。 +$git push -u origin master + 把本地库的内容推送到远程,由于是第一次推送master分支,所以加上了-u参数。 + git不但把本地master分支内容推送到远程新master分支,还会把本地的master + 分支和远程master分支关联起来。 + 之后push就不需要-u参数了。 +$git clone “remote rep site" + 克隆远程库到本地 + +分支部分: + +$git checkout -b dev + 创建分支(名称为dev),然后切换到dev分支 + -b表示创建并切换,相当于一下: + $git branch dev 创建dev分支 + $git checkout dev 切换到dev分支 +$git branch + 查看当前分支 +$git merge dev + 合并分支dev +$git branch -d dev + 删除分支 +$git branch -D dev + 强行删除分支 +$git log —graph + 查看分支合并图 +$git merge —no-ff -m “msg” dev + 禁用fast forward合并,保留分支合并信息 + +$git stash + 保存现场,转到其他分支 +$git stash list + 查看保存的现场list +$git stash apply + 恢复某现场 +$git stash pop + 恢复并删除某现场 +$git stash drop + 删除某现场 + +$git remote + 查看远程库信息 +$git remote -v + 远程库详细信息 +$git checkout -b dev origin/dev + 创建本地dev分支,对应远程dev分支 + +$git branch —set-upstream dev origin/dev + 创建本地与远程dev分支的链接 + +$git tag ’tagname' + 打标签 +$git tag + 查看标签 +$git tag ’tagname’ ‘commit id' + 对指定commit id对应提交打标签 +$git show 'tagname' + + diff --git a/readme.txt b/readme.txt index 3958cf1aa7..cb3cb7f285 100644 --- a/readme.txt +++ b/readme.txt @@ -4,3 +4,7 @@ Git has a mutable index called stage. Git tracks changes of files. Creating a new branch is quick and simple. Git can merge branches. +"test pull request." +update by wk +update by frogy + diff --git a/recoba20.txt b/recoba20.txt new file mode 100644 index 0000000000..f1490d490f --- /dev/null +++ b/recoba20.txt @@ -0,0 +1 @@ +教程非常赞,我试试能不能pull? \ No newline at end of file diff --git a/redHL.txt b/redHL.txt new file mode 100644 index 0000000000..34db8573ed --- /dev/null +++ b/redHL.txt @@ -0,0 +1 @@ +不是很清楚标签的作用,标签管理上面可以再详细点。像分支管理就写得很详细。 \ No newline at end of file diff --git a/relsoul.txt b/relsoul.txt new file mode 100644 index 0000000000..70cb9a6cc6 --- /dev/null +++ b/relsoul.txt @@ -0,0 +1,243 @@ + + +本文是GitHub个人学习笔记. + +下载与安装GitHub + +下载 GitHub For Windows :https://windows.github.com/ + +PS:推荐架设VPN..下载和访问速度不忍直视啊 + + + +Git Shell + +创建版本库 + +在桌面打开Git Shell即进入了shell模式 + +新建文件夹>> mkdir初始化版本库>> git init + +添加文件 + +添加文件>>git add [file1 file2 file3...] + +提交文件到仓库>>git commit -m "第一次提交文件压力山大" + +回溯 + +查看是否存在改动未提交的文件>>git status + +查看文件改动信息>>git diff + +查看git改动日志>>git log + +简单显示git改动日志>>git log --pretty=oneline + +回溯git>>git reset --hard HEAD^ 一个^代表回溯到上一个版本^^两个回溯到上上个版本.... + +显示回溯日志>>git reflog + +回溯git(通过commit id)>>git reset --hard 3628164 + +工作区与暂存区详细说明:click + +git add提交说明 + +git做的是修改管理,修改包括.文件,动作 + +比如第一次我在readme.txt文件写了一行 + +hello world + +然后用git add命令进行添加,但是我突然想写一行 + +bey bey + +于是修改后不再次添加直接 git commit -m "xxx" + +然后再执行git status发现还有个readme.txt文件修改未被提交 + +原理很简单 + +第一次add添加的是hello world 这个文件放到了缓存区 + +然后你又添加了一行代码 beybey 于是这个文件又被放到了缓存区 + +也就是说缓存区有两个readme.txt + +理解了后就好办了,可以第一次修改的时候不add readme.txt + +或者第二次修改后再次使用 add readme.txt合并两个文件 再进行git commit -m添加 + +用git diff HEAD -- readme.txt命令可以查看工作区和版本库里面最新版本的区别: + +撤销修改 + +回到最近一次git commit或git add时的状态>>git checkout -- readme.txt + +添加到缓存区后撤销操作>>git reset HEAD file (然后再用checkout命令继续撤销) + +撤销添加到本地仓库未添加到远程仓库>>git reset --hard HEAD^ + + + +删除文件 + +从版本库中删除文件>>git rm flie + +接着再提交动作 git commit -m "删除一个文件" + + 远程仓库 + +添加远程库>>git remote add 代号(自行填写) git@github.com:你的账户名/仓库名.git + +错误提示:(本地已经存在这个远程仓库) fatal: remote origin already exists. +解决办法:(移除这个远程仓库) git remote rm origin +推送文件至远程库>>git push -u origin master + +PS:由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。 + +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; + +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; + +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + + 克隆远程库 + +git clone git@github.com:账户名/仓库名.git + + + +创建与合并分支 + +创建切换到dev分支>>git checkout -b dev + +git checkout命令加上-b参数表示创建并切换,相当于以下两条命令: + +$ git branch dev +$ git checkout dev +查看当前分支>>git branch (git branch命令会列出所有分支,当前分支前面会标一个*号) + +切换分支>>git checkout 分支名 + +合并分支>>git merge 分支名(移动到其他分支后使用此命令合并分支名) + +删除分支>>git branch -d 分支名 + + + +解决合并冲突 + +首先创建一个git checkout -b soul分支soul + +然后再readme.txt文件增加一行 + +soul readme + +提交一下readme.txt + +然后切换回master分支 + +然后修改master分支下的readme.txt + +master readme + +提交一下readme.txt + +然后执行一下合并git merge soul + +Auto-merging readme.txt +CONFLICT (content): Merge conflict in readme.txt +Automatic merge failed; fix conflicts and then commit the result. + +发现会报错 git无法执行快速合并 + +用git status也会提示冲突文件 + +于是我们需要手动处理 + +查看readme.txt文件 + +Git用<<<<<<<,=======,>>>>>>>标记出不同分支的内容 + +我们修改readme.txt文件 + +删除git生成的<<<<< ====== >>>>>>然后把test分支上readme.txt的内容添加到readme.txt里就ok了 + +然后git add readme.txt git commit -m "fix" + +分支管理策略 + +通常合并分支git都是使用Fast forward,但这种模式下,删除分支后,会丢掉分支信息 + +如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。 + +$ git merge --no-ff -m "merge with no-ff" dev + +Merge made by the 'recursive' strategy. readme.txt | 1 + + +1 file changed, 1 insertion(+) + +因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。 + +Git分支十分强大,在团队开发中应该充分应用。 + +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 + + + +Bug分支 + +比如我在dev分支下修改readme.txt时需要去master分支上修改一个bug + +于是我可以利用 + +储藏>>git stash + +当前的工作 然后切换至master上创建一个临时分支bugfix然后修改readme.txt + +修改完毕后git add readme.txt; git commit -m "fixbug" + +然后切换到master分支来 + +git merge --no-ff -m "merged bug fix 101" bugfix + +合并下bugfix 然后 + +git branch -d bugfix + +删除这个分支 + +切换到dev分支 + +工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: + +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; + +另一种方式是用git stash pop,恢复的同时把stash内容也删了:再用git stash list查看,就看不到任何stash内容了: + +利用 git stash pop恢复下内容 就可以继续工作了 + + + +强行删除分支 + +在未合并分支的情况下删除分支 + +git branch -d bugfix git会报错 + +于是我们可以使用 + +强行删除>>git branch -D (其实就把小写d改为大写D) + +然后就删除完毕了 + + 多人协作 + +真羡慕有两台电脑的人2333 + +详情去click me 这个网站观看~ + + \ No newline at end of file diff --git a/renguochao.txt b/renguochao.txt new file mode 100644 index 0000000000..c99ef0488a --- /dev/null +++ b/renguochao.txt @@ -0,0 +1,2 @@ +Thanks for your git blog, i learn a lot from it. +Writen by Guochao Ren. diff --git a/rtfs.txt b/rtfs.txt new file mode 100644 index 0000000000..bf72aa6268 --- /dev/null +++ b/rtfs.txt @@ -0,0 +1 @@ +Great work mickael. Your tutorial helps me a lot. diff --git a/ryan_learn_git b/ryan_learn_git new file mode 100644 index 0000000000..6a94a34876 --- /dev/null +++ b/ryan_learn_git @@ -0,0 +1 @@ +Thank you liao~ diff --git a/sailing367.txt b/sailing367.txt new file mode 100644 index 0000000000..34ce3445ef --- /dev/null +++ b/sailing367.txt @@ -0,0 +1 @@ +Thanks for your share. diff --git a/sanbingo.txt b/sanbingo.txt new file mode 100644 index 0000000000..9130a58b16 --- /dev/null +++ b/sanbingo.txt @@ -0,0 +1 @@ +Stay hungry,Stay foolish! diff --git a/sanmisanFan.txt b/sanmisanFan.txt new file mode 100644 index 0000000000..c81c38c036 --- /dev/null +++ b/sanmisanFan.txt @@ -0,0 +1,6 @@ +Dear Michael, + +Hello, I am a postgraduate student and just start using git instead of SVN. +I have learned a lot from your amazing git tutorial. Thank you Michael! + +Sanmisan Fan diff --git a/sck-rookie.txt b/sck-rookie.txt new file mode 100644 index 0000000000..3fab02cdad --- /dev/null +++ b/sck-rookie.txt @@ -0,0 +1 @@ +The most wonderful tutorial i've ever seen! diff --git a/sdlyjzh.txt b/sdlyjzh.txt new file mode 100644 index 0000000000..25435c1a29 --- /dev/null +++ b/sdlyjzh.txt @@ -0,0 +1 @@ +Thank you a lot! It really helpful! diff --git a/seancy.txt b/seancy.txt new file mode 100644 index 0000000000..9218c7cccf --- /dev/null +++ b/seancy.txt @@ -0,0 +1,3 @@ + +这是我第二次学习廖雪峰老师的教程,此教程以通俗易懂的方式,从实用角度介绍了git的常用命令,如果你能通读这篇教程,使用git与人合作开发应该不成问题。推荐学习 + diff --git a/secondrocker.txt b/secondrocker.txt new file mode 100644 index 0000000000..cf645cd301 --- /dev/null +++ b/secondrocker.txt @@ -0,0 +1,2 @@ +my name is secondrocker +for the lich king diff --git a/sevengods.txt b/sevengods.txt new file mode 100644 index 0000000000..c8f20f9d35 --- /dev/null +++ b/sevengods.txt @@ -0,0 +1 @@ +一直在看廖老师的git教程,写的真好,谢谢廖老师的分享 diff --git a/sexy_tutorial.txt b/sexy_tutorial.txt new file mode 100644 index 0000000000..f6ed6f343e --- /dev/null +++ b/sexy_tutorial.txt @@ -0,0 +1,2 @@ +Great tutorial. cool! +Thanks Michael Liao. \ No newline at end of file diff --git a/sheisalwayswalking b/sheisalwayswalking new file mode 100644 index 0000000000..cc4d70af3b --- /dev/null +++ b/sheisalwayswalking @@ -0,0 +1,2 @@ +感谢廖老师得课程,感觉Git得功能真心很强大,~>_<~ +我会继续学习下去滴! diff --git a/shirleyChou.txt b/shirleyChou.txt new file mode 100644 index 0000000000..4971b22ca6 --- /dev/null +++ b/shirleyChou.txt @@ -0,0 +1 @@ +Your tutorial of learning git is a great and concise guidance for me. Thank you very much for that! diff --git a/shixiong77.txt b/shixiong77.txt new file mode 100644 index 0000000000..8b34b17f9d --- /dev/null +++ b/shixiong77.txt @@ -0,0 +1,3 @@ +Very good! +After read your blog for git,i'm trying use github.It's so easy and efficient. +Thanks a lot! diff --git a/shiyipingmi.txt b/shiyipingmi.txt new file mode 100644 index 0000000000..8711395c89 --- /dev/null +++ b/shiyipingmi.txt @@ -0,0 +1,3 @@ +Dear Michael Liao + Thanks for your great course.This is my first day on the job,My boss need to us to finish this course,and want us to +establish Ali cloud server.Oh ,my god ,I'm going crazy.Fortunately,there has your great course.Thanks sincely \ No newline at end of file diff --git a/sin-zx.txt b/sin-zx.txt new file mode 100644 index 0000000000..c595a691fd --- /dev/null +++ b/sin-zx.txt @@ -0,0 +1,4 @@ +# Thanks! Your course is lively and easy to learn how to use such a great tool. +# I have learned a lot. +# I am going on a way to be a great programmer like you.Hope i can do that. +# Thanks. diff --git a/siriushr.txt b/siriushr.txt new file mode 100644 index 0000000000..580f5fae3c --- /dev/null +++ b/siriushr.txt @@ -0,0 +1,2 @@ +Thank you Michael. +I've learned a lot from your git guide. diff --git a/skf321.txt b/skf321.txt new file mode 100644 index 0000000000..bb881ae5cd --- /dev/null +++ b/skf321.txt @@ -0,0 +1 @@ +good job, michael liao, thanks a lot, wish u happy ^_^ diff --git a/sklthegoodman.txt b/sklthegoodman.txt new file mode 100644 index 0000000000..b2f882c03f --- /dev/null +++ b/sklthegoodman.txt @@ -0,0 +1 @@ +一个很棒的教程,浅显易懂,非常感谢!!!过几天购买ios app以示感谢。 \ No newline at end of file diff --git a/smallzzuni.txt b/smallzzuni.txt new file mode 100644 index 0000000000..0161bcd2c4 --- /dev/null +++ b/smallzzuni.txt @@ -0,0 +1 @@ +smallzzuni.txt test for learngit \ No newline at end of file diff --git a/smartoray.txt b/smartoray.txt new file mode 100644 index 0000000000..2d018a7981 --- /dev/null +++ b/smartoray.txt @@ -0,0 +1 @@ +Liao, thanks for your hard work! diff --git a/snowberry.txt b/snowberry.txt new file mode 100644 index 0000000000..1d33e34280 --- /dev/null +++ b/snowberry.txt @@ -0,0 +1,3 @@ +pull request +################# +一口气看完了,非常好的教程,通过图解的方式来说明,非常好,好的教程! diff --git a/songpku.txt b/songpku.txt new file mode 100644 index 0000000000..5f222d95c0 --- /dev/null +++ b/songpku.txt @@ -0,0 +1 @@ +thanks \ No newline at end of file diff --git a/soochowshanshan.txt b/soochowshanshan.txt new file mode 100644 index 0000000000..9bfc0aa798 --- /dev/null +++ b/soochowshanshan.txt @@ -0,0 +1,5 @@ +This is a test file from soochowshanshan. + +Thank you,liao. + +2015/05/26 diff --git a/starshiner b/starshiner new file mode 100644 index 0000000000..801fa9cead --- /dev/null +++ b/starshiner @@ -0,0 +1 @@ +看了廖老师的教程之后,感觉又会爱了 diff --git a/statby.txt b/statby.txt new file mode 100644 index 0000000000..55971cfcf4 --- /dev/null +++ b/statby.txt @@ -0,0 +1 @@ +终于迈出这一步,学习了git,感谢liao diff --git a/stefancc_.txt b/stefancc_.txt new file mode 100644 index 0000000000..c41885994e --- /dev/null +++ b/stefancc_.txt @@ -0,0 +1 @@ +测试下是否支持中文的文件名 谢谢廖老师! \ No newline at end of file diff --git a/study.test b/study.test new file mode 100644 index 0000000000..fce38688f8 --- /dev/null +++ b/study.test @@ -0,0 +1 @@ +正在学习github的使用,很好的教程,谢谢! diff --git a/sulingzhi.txt b/sulingzhi.txt new file mode 100644 index 0000000000..b7cd1822d0 --- /dev/null +++ b/sulingzhi.txt @@ -0,0 +1,2 @@ + +my test \ No newline at end of file diff --git a/suweya.txt b/suweya.txt new file mode 100644 index 0000000000..0ff57a3fe7 --- /dev/null +++ b/suweya.txt @@ -0,0 +1 @@ +Thank you! \ No newline at end of file diff --git a/swead.txt b/swead.txt new file mode 100644 index 0000000000..5846941b4b --- /dev/null +++ b/swead.txt @@ -0,0 +1,3 @@ +It's a test. +Thanks you. +Swead \ No newline at end of file diff --git a/swk1992.txt b/swk1992.txt new file mode 100644 index 0000000000..d1f7a081e7 --- /dev/null +++ b/swk1992.txt @@ -0,0 +1 @@ +swk1992 \ No newline at end of file diff --git a/tangculijier.txt b/tangculijier.txt new file mode 100644 index 0000000000..dddc7b4f6b --- /dev/null +++ b/tangculijier.txt @@ -0,0 +1 @@ +Thanks! \ No newline at end of file diff --git a/targeral.txt b/targeral.txt new file mode 100644 index 0000000000..91993521f0 --- /dev/null +++ b/targeral.txt @@ -0,0 +1,141 @@ +命令: +git init初始化一个git仓库 +git add 添加一个文件到仓库 +git commit -m "xxx" m后面输入的是本次提交的说明,可以输入任意内容,当然最好是有意义的,这样你就能从历史记录里方便地找到改动记录。 +git status查看仓库当前状态 +git diff 查看具体修改内容 +git log 查看历史记录 如果嫌输出信息太多,看得眼花缭乱的,可以试试加上--pretty=oneline参数 +* HEAD表示当前版本 上一个版本就是HEAD^ 上上个就是HEAD^^ 往上100个可以写成HEAD~100 +git reset --hard HEAD^ (可变)版本回退,也可以把暂存区的修改会退到工作区。当我们使用HEAD时,表示最新版本 +可以通过指定commit id的前几位回退到那个版本 +git reflog 查看你的每一次命令,通过它查看commit id +* Git跟踪并管理的是修改,而非文件 +git checkout -- 撤销修改,使文件回到最近一次git commit or git add (“--”这个不可丢 否则成了另一个命令) +* + 场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 + 场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 + 场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库 +* +git rm 删除一个文件。如果一个文件已经被提交到版本库,那么你永远不用担心误删,但是要小心,你只能恢复文件到最新版本,你会丢失最近一次提交后你修改的内容 +git checkout其实是用版本库里的版本替换工作区的版本,无论工作区是修改还是删除,都可以“一键还原”。 + +* +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; +* + +* +要克隆一个仓库,首先必须知道仓库的地址,然后使用git clone命令克隆。 +Git支持多种协议,包括https,但通过ssh支持的原生git协议速度最快。 +* +git checkout -b 创建分支 +git checkout 切换分支 +git branch查看当前分支 +git merge用于合并指定分支到当前分支 +* Fast-forward 快进模式 +git branch -d 删除分支 + +* +Git鼓励大量使用分支: + +查看分支:git branch + +创建分支:git branch + +切换分支:git checkout + +创建+切换分支:git checkout -b + +合并某分支到当前分支:git merge + +删除分支:git branch -d + +* + +* +当Git无法自动合并分支时,就必须首先解决冲突。解决冲突后,再提交,合并完成 + +git log --graph --pretty=oneline --abbrev-commit 命令可以看到分支合并图。 +* + +* +分支策略 + +在实际开发中,我们应该按照几个基本原则进行分支管理: + +首先,master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活; + +那在哪干活呢?干活都在dev分支上,也就是说,dev分支是不稳定的,到某个时候,比如1.0版本发布时,再把dev分支合并到master上,在master分支发布1.0版本; + +你和你的小伙伴们每个人都在dev分支上干活,每个人都有自己的分支,时不时地往dev分支上合并就可以了。 +* + +* +git merge --no-ff -m <分支> +合并分支时,加上--no-ff参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而fast forward合并就看不出来曾经做过合并。 +* + +* +某个分支出现bug时,首先将当前分支的任务“储藏” +git stash +在有问题的分支上创建解决问题的临时分支iusse-101 +修复bug +修复后,切换原来分支,合并并删除临时分支iusse-101 +回到工作分支,有两种方式回复工作: +1.git stash apply恢复,git stash drop 来删除stash内容 +2.git stash pop恢复同时删除 + +git stash list查看stash内容 +在多次stash,恢复的时候,先用git stash list 查看,然后恢复指定的stash,用命令: +git stash apply stash@{n} +* + +* +开发一个新feature,最好新建一个分支; + +如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 +* + +* +查看远程库信息,使用git remote -v; + +本地新建的分支如果不推送到远程,对其他人就是不可见的; + +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 +* +git tag 创建标签 +git tag查看所有标签 + +* +对于已经过去的某一个commit打上标签 可以这样: +git log --pretty=oneline --abbrev-commit +查看commit id,然后 +git tag v0.9 commit-id +注意,标签不是按时间顺序列出,而是按字母排序的。可以用 +git show +查看标签信息 +可以创建带有说明的标签,用-a指定标签名,-m指定说明文字: +git tag -a v0.1 -m "version 0.1 released" 3628164 + +git tag -s -m "blablabla..."可以用PGP签名标签; +* + +* +操作标签 +git tag -d 删除 +git push orign 推送远程 +git push origin --tags 一次全部推送 + +删除远程标签 +先删除本地 +git tag -d +然后从远程删除 +git push orgin :refs/tags/ +* \ No newline at end of file diff --git a/teacher-Liao-is-a-good-teacher.txt b/teacher-Liao-is-a-good-teacher.txt new file mode 100644 index 0000000000..7cf09ffadb --- /dev/null +++ b/teacher-Liao-is-a-good-teacher.txt @@ -0,0 +1 @@ +thank you , teacher Liao. diff --git a/tedfortest.txt b/tedfortest.txt new file mode 100644 index 0000000000..2662fef898 --- /dev/null +++ b/tedfortest.txt @@ -0,0 +1 @@ +i want to say thank u for mr.liao for teaching me how to use git. \ No newline at end of file diff --git a/terryyeb.txt b/terryyeb.txt new file mode 100644 index 0000000000..8bd397ffc3 --- /dev/null +++ b/terryyeb.txt @@ -0,0 +1 @@ +廖老师的课程太棒了,得 赞助啊! diff --git a/test-AngiWANG.txt b/test-AngiWANG.txt new file mode 100644 index 0000000000..d86cee9781 --- /dev/null +++ b/test-AngiWANG.txt @@ -0,0 +1 @@ +ѧϰ״IJллṩƪ \ No newline at end of file diff --git a/test-pull-request b/test-pull-request new file mode 100644 index 0000000000..7aa51afad9 --- /dev/null +++ b/test-pull-request @@ -0,0 +1 @@ +hello michaelliao diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..ace28ac702 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +thank you for your git article~ diff --git a/testGitPull.txt b/testGitPull.txt new file mode 100644 index 0000000000..5350da2875 --- /dev/null +++ b/testGitPull.txt @@ -0,0 +1 @@ +测试一下git推送,哈哈 diff --git a/test_abc.txt b/test_abc.txt new file mode 100644 index 0000000000..066a56554b --- /dev/null +++ b/test_abc.txt @@ -0,0 +1 @@ +教程写得通俗易懂,不错。谢谢! \ No newline at end of file diff --git a/test_for_pull_request.txt b/test_for_pull_request.txt new file mode 100644 index 0000000000..8e9c0da000 --- /dev/null +++ b/test_for_pull_request.txt @@ -0,0 +1,2 @@ +在这里尝试下贡献代码。 +谢谢你的文章,让我知道怎么使用git。 diff --git a/test_fork_1109.txt b/test_fork_1109.txt new file mode 100644 index 0000000000..306691a1f3 --- /dev/null +++ b/test_fork_1109.txt @@ -0,0 +1 @@ +good tutorial. \ No newline at end of file diff --git a/test_fork_pull.txt b/test_fork_pull.txt new file mode 100644 index 0000000000..9facc25238 --- /dev/null +++ b/test_fork_pull.txt @@ -0,0 +1,3 @@ +Forkܺpull reques +лƪ +л¥+1 \ No newline at end of file diff --git a/test_learning_pull_request.txt b/test_learning_pull_request.txt new file mode 100644 index 0000000000..af1964c782 --- /dev/null +++ b/test_learning_pull_request.txt @@ -0,0 +1,5 @@ +谢谢廖老师! +教学方法很得当。关注于课程主题,忽略其他不重要的知识(比如vi的使用)。 +让学生在轻松愉快的氛围下就学到了很多知识。 +学完这个以后将会继续学习廖老师的python教程。 +再次谢谢廖老师! diff --git a/test_pull.txt b/test_pull.txt new file mode 100644 index 0000000000..45f4e185f2 --- /dev/null +++ b/test_pull.txt @@ -0,0 +1,2 @@ +this line has no contents. +test \ No newline at end of file diff --git a/test_pull_request_dee.txt b/test_pull_request_dee.txt new file mode 100644 index 0000000000..b95dfe7831 --- /dev/null +++ b/test_pull_request_dee.txt @@ -0,0 +1 @@ +这个git系列教程真的做得十分不错.深入浅出.谢谢博主. diff --git a/test_pull_request_ping.txt b/test_pull_request_ping.txt new file mode 100644 index 0000000000..1885550ce0 --- /dev/null +++ b/test_pull_request_ping.txt @@ -0,0 +1,5 @@ +Hi Mr Liao, +Your blog bring me a powerful benefit, thanks a lot. + +Best regards +Ping diff --git a/test_try_pull.txt b/test_try_pull.txt new file mode 100644 index 0000000000..9adbbc98b9 --- /dev/null +++ b/test_try_pull.txt @@ -0,0 +1 @@ +I just want to try. diff --git a/testbytpg.txt b/testbytpg.txt new file mode 100644 index 0000000000..c0bcfb9fc2 --- /dev/null +++ b/testbytpg.txt @@ -0,0 +1 @@ +thank you! \ No newline at end of file diff --git a/testpull b/testpull new file mode 100644 index 0000000000..b4b78d23ce --- /dev/null +++ b/testpull @@ -0,0 +1 @@ +what is this for ? diff --git a/thank b/thank new file mode 100644 index 0000000000..931e9f575f --- /dev/null +++ b/thank @@ -0,0 +1 @@ +谢谢作者 diff --git a/thank you b/thank you new file mode 100644 index 0000000000..4e8641e535 --- /dev/null +++ b/thank you @@ -0,0 +1 @@ +this is my first github fork,thank you. diff --git a/thank.you b/thank.you new file mode 100644 index 0000000000..e5408f3c41 --- /dev/null +++ b/thank.you @@ -0,0 +1,3 @@ +lucky to meet your article. +git is a good tool. +should be better. diff --git a/thankU.txt b/thankU.txt new file mode 100644 index 0000000000..2aef5541e3 --- /dev/null +++ b/thankU.txt @@ -0,0 +1 @@ +Thank you very much! \ No newline at end of file diff --git a/thank_gitstudy.txt b/thank_gitstudy.txt new file mode 100644 index 0000000000..1f0d08b52a --- /dev/null +++ b/thank_gitstudy.txt @@ -0,0 +1 @@ +Thank you for your tutorial,Michael! \ No newline at end of file diff --git a/thank_you.txt b/thank_you.txt new file mode 100644 index 0000000000..c178845a77 --- /dev/null +++ b/thank_you.txt @@ -0,0 +1,3 @@ +Dear 廖大大: + 您好,用了不到三天的时间把这套Git教程学习完了。教程很好,之前一直很自卑,感觉自己什么都不会,连Git都不知道到底是个什么东西。在这三天中通过对Git的学习,增加了自信,虽然用的还不是很熟练,很多命令还要在查,但是通过这套教程地学习,不仅学会了Git的使用,而且加深了对shell的使用,对Vim的使用,在学习工程中,为了删除根目录下的一个隐藏文件,还误把根目录删了,这更加深了对Git学习地决心,以后项目都放到GitHub上:) + 之前在断断续续地看您地python的教程,之后也会继续加深对python的学习,总之,感谢您! diff --git a/thanks b/thanks new file mode 100644 index 0000000000..45c3c6444d --- /dev/null +++ b/thanks @@ -0,0 +1,2 @@ +真的非常感谢这么用心良苦的教程。 +真的跟着操作一天学会,没有比这更简单的教程了。 \ No newline at end of file diff --git a/thanks letter b/thanks letter new file mode 100644 index 0000000000..6141fc6b17 --- /dev/null +++ b/thanks letter @@ -0,0 +1,3 @@ +I am reading your blog, http://www.liaoxuefeng.com. +Amazing +十分感谢 diff --git a/thanks.txt b/thanks.txt new file mode 100644 index 0000000000..2091cb07fa --- /dev/null +++ b/thanks.txt @@ -0,0 +1 @@ +thank you,Michael Liao. diff --git a/thanksforyou.txt b/thanksforyou.txt new file mode 100644 index 0000000000..9a9f07804b --- /dev/null +++ b/thanksforyou.txt @@ -0,0 +1 @@ +感谢楼主,终于搞明白git的使用了,能力大大提升!!! \ No newline at end of file diff --git a/thanksmichaelliao.txt b/thanksmichaelliao.txt new file mode 100644 index 0000000000..51b2c7d064 --- /dev/null +++ b/thanksmichaelliao.txt @@ -0,0 +1 @@ +thanks michaelliao \ No newline at end of file diff --git a/thankyou b/thankyou new file mode 100644 index 0000000000..ad5c99aa2d --- /dev/null +++ b/thankyou @@ -0,0 +1 @@ +thank you liao!I'm a student and start to learn git! diff --git a/thankyou.toyou b/thankyou.toyou new file mode 100644 index 0000000000..3ff757dac7 --- /dev/null +++ b/thankyou.toyou @@ -0,0 +1,6 @@ +t@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git +git@github.com:loyabe/learngit.git + diff --git a/thankyou.txt b/thankyou.txt new file mode 100644 index 0000000000..584e62e760 --- /dev/null +++ b/thankyou.txt @@ -0,0 +1 @@ +Thanks for the wonderful tutorial! diff --git a/thankyou_txt b/thankyou_txt new file mode 100644 index 0000000000..19072713f7 --- /dev/null +++ b/thankyou_txt @@ -0,0 +1,2 @@ +thank you. +very much. diff --git a/theqwang.txt b/theqwang.txt new file mode 100644 index 0000000000..01aae4175a --- /dev/null +++ b/theqwang.txt @@ -0,0 +1,3 @@ +Hello liao +I am theqwang.Recently,I am learning Python and Git from your website. +without you,I can not grow up so fast.You are a good man,thank you very much! diff --git a/thk_you b/thk_you new file mode 100644 index 0000000000..76b0173826 --- /dev/null +++ b/thk_you @@ -0,0 +1 @@ +your blog is very useful for me ,thank you! diff --git a/tjjx8.txt b/tjjx8.txt new file mode 100644 index 0000000000..3462721fd4 --- /dev/null +++ b/tjjx8.txt @@ -0,0 +1 @@ +hello! \ No newline at end of file diff --git a/tonylmd.txt b/tonylmd.txt new file mode 100644 index 0000000000..f402bcb593 --- /dev/null +++ b/tonylmd.txt @@ -0,0 +1,2 @@ +Thank a lot to liuxuefeng, the author of the Chinese version Git Tutorial. +This file is a part of my learning, trying to submit a pull request. diff --git a/truthpierce.txt b/truthpierce.txt new file mode 100644 index 0000000000..3d28bbb0eb --- /dev/null +++ b/truthpierce.txt @@ -0,0 +1,3 @@ +很棒的教程。从来没有系统学过,看到这个教程又重新过了一遍。非常感谢。 + +如果说有什么心得,就是教程里有些过时的内容。比如多人协作里--set-upstream参数已经不再适用,可以替换为--track或--set-upstream-to,希望能够及时更新。 diff --git a/tshua.txt b/tshua.txt new file mode 100644 index 0000000000..4d3a6f6cd4 --- /dev/null +++ b/tshua.txt @@ -0,0 +1,2 @@ +我是一名大学生,学新东西的时候总是遇到选择的教材不合适,学习路线不合理等问题导致学习效率低下。 +非常感谢廖老师,您的教程很棒! \ No newline at end of file diff --git a/tuotuo.txt b/tuotuo.txt new file mode 100644 index 0000000000..a8bc975567 --- /dev/null +++ b/tuotuo.txt @@ -0,0 +1 @@ +谢谢你,你的博客写的非常好! diff --git a/turing369.txt b/turing369.txt new file mode 100644 index 0000000000..69fd529779 --- /dev/null +++ b/turing369.txt @@ -0,0 +1 @@ +just a test! diff --git a/tuzhis.txt b/tuzhis.txt new file mode 100644 index 0000000000..f6b9ea1f2b --- /dev/null +++ b/tuzhis.txt @@ -0,0 +1 @@ +thank you for your help diff --git a/tzp-github-1.txt b/tzp-github-1.txt new file mode 100644 index 0000000000..ea6411986f --- /dev/null +++ b/tzp-github-1.txt @@ -0,0 +1 @@ +My name is tzp,I am glad to see you. \ No newline at end of file diff --git a/uniquetree.txt b/uniquetree.txt new file mode 100644 index 0000000000..e1d79e59a5 --- /dev/null +++ b/uniquetree.txt @@ -0,0 +1,2 @@ +非常感谢廖老师这份git教程,我是看过其他教程再来看这份的,这让我会的再熟悉了一遍,也填补了我的不会的(例如pull request, +还让我亲身体验一番,nice)!Thanks you! diff --git a/uxzhou.txt b/uxzhou.txt new file mode 100644 index 0000000000..5e189d5ecb --- /dev/null +++ b/uxzhou.txt @@ -0,0 +1,5 @@ +Hi Michael Liao, + +I am UX Designer. This blog profoundly change my way of thinking in terms of github learning. + +You are really a great mentor. Thank you so much. I learned a lot. \ No newline at end of file diff --git a/vacing.txt b/vacing.txt new file mode 100644 index 0000000000..014e0c93c3 --- /dev/null +++ b/vacing.txt @@ -0,0 +1,6 @@ +Hello, everyone, + This is vacing, from uestc, at Nov 20th, 2014. + Very glad to learn this material, it's very useful. + Thank you cichaelliao. + Yours sincere + vacing diff --git a/very-good.txt b/very-good.txt new file mode 100644 index 0000000000..e66448f5ab --- /dev/null +++ b/very-good.txt @@ -0,0 +1 @@ +Nice! diff --git a/veyron1110.txt b/veyron1110.txt new file mode 100644 index 0000000000..b6d738f5d5 --- /dev/null +++ b/veyron1110.txt @@ -0,0 +1,5 @@ +Hi sir, + +Your tutorial is so great that I can't resist to recommend it to my friends. + +Best diff --git a/vincent-wjj.txt b/vincent-wjj.txt new file mode 100644 index 0000000000..cb90444fc0 --- /dev/null +++ b/vincent-wjj.txt @@ -0,0 +1 @@ +As for a work,I study you toturial! Thanks a lot for these wonderful feeds! diff --git a/vincentping.txt b/vincentping.txt new file mode 100644 index 0000000000..7021a28189 --- /dev/null +++ b/vincentping.txt @@ -0,0 +1 @@ +Thanks you for the git tutorial! diff --git a/vinson0420@163.com.txt b/vinson0420@163.com.txt new file mode 100644 index 0000000000..467767e5fb --- /dev/null +++ b/vinson0420@163.com.txt @@ -0,0 +1,2 @@ +Thank you for giving so good a session. +I like it! diff --git a/voidmous.txt b/voidmous.txt new file mode 100644 index 0000000000..7eaa770069 --- /dev/null +++ b/voidmous.txt @@ -0,0 +1,2 @@ +很漂亮的教程,一个上午学完,感谢! +20块钱请你吃个夜宵,微信ID:voidmous diff --git a/volterra.txt b/volterra.txt new file mode 100644 index 0000000000..1421718f68 --- /dev/null +++ b/volterra.txt @@ -0,0 +1 @@ +Thanks Mr.Liao! Really meaningful and awesome work! diff --git a/vra.txt b/vra.txt new file mode 100644 index 0000000000..30b6463371 --- /dev/null +++ b/vra.txt @@ -0,0 +1,3 @@ +This is thankyou file from vra +Thank you sincerely. + diff --git a/w10001.txt b/w10001.txt new file mode 100644 index 0000000000..7ec9a4b774 --- /dev/null +++ b/w10001.txt @@ -0,0 +1 @@ +aa \ No newline at end of file diff --git a/wangshaochen.txt b/wangshaochen.txt new file mode 100644 index 0000000000..a85f125ab1 --- /dev/null +++ b/wangshaochen.txt @@ -0,0 +1,108 @@ +git笔记 +yum install git +git init 初始化 +git add file 添加到仓库 +git commit -m "the help " 提交到仓库 +git status +git diff file +git log 如果嫌输出信息太多,看得眼花缭乱的,可以试试加上--pretty=oneline参数 +git reset --hard HEAD^ 回滚到上个版本 +git reset --hard 3628164(版本id前几位) +git reflog 记录每一次命令 + +git checkout file 丢弃工作区更改 +git reset HEAD file 撤销暂存区的修改 +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库 + + +git rm file +git commit -m "rm file"删除文件 +git checkout file 恢复工作区误删除文件 + + +ssh-keygen -t rsa -C "youremail@example.com" +git remote add origin wangshaochen@github.com:wangshaochen/learngit.git +git remote add origin git@server-name:path/repo-name.git +git push -u origin master /-u 关联仓库 +git push origin master + + + git clone git@github.com:michaelliao/gitskills.git + + +git branch 查看分支 +git branch 新建分支 +git checkout 切换分支 +git checkout -b 新建并切换到分支 +git merge 合并某分支到主分支 +git branch -d 删除分支 +合并分区发生冲突后修改后再合并 + + + + +git merge --no-ff -m "merge with no-ff" dev 普通合并 +git stash bug分支,存贮后台 +git stash pop 调出后台工作内容,并删除 +git stash list +git stash apply stash@{0} +git branch -D 强行删除 + + + + +因此,多人协作的工作模式通常是这样: + + + + 1. 首先,可以试图用git push origin branch-name推送自己的修改; + + 2. 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + + 3. 如果合并有冲突,则解决冲突,并在本地提交; + + 4. 没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + + + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + +这就是多人协作的工作模式,一旦熟悉了,就非常简单。 + + + + * +查看远程库信息,使用git remote -v; + + * 本地新建的分支如果不推送到远程,对其他人就是不可见的; + + * 从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + + * 在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + + * 建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + + * +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + + * 命令git tag 用于新建一个标签,默认为HEAD,也可以指定一个commit id; + + * git tag -a -m "blablabla..."可以指定标签信息; + + * git tag -s -m "blablabla..."可以用PGP签名标签; + + * +命令git tag可以查看所有标签。 + +git tag -d v0.1 删除标签本地 +git push origin 推送标签到远程 +git push origin --tags 推送全部未推送的标签 +git tag -d v0.9 +git push origin :refs/tags/v0.9 删除远程标签 + + + + diff --git a/wangshui26.txt b/wangshui26.txt new file mode 100644 index 0000000000..458055f5ea --- /dev/null +++ b/wangshui26.txt @@ -0,0 +1 @@ +中午好啊...... \ No newline at end of file diff --git a/wangxiaobupt.txt b/wangxiaobupt.txt new file mode 100644 index 0000000000..851a8271fb --- /dev/null +++ b/wangxiaobupt.txt @@ -0,0 +1,5 @@ +Thank you so much . + +I have learned a lot and it make me happy . + + diff --git a/wangzhizhou2014GitHub.txt b/wangzhizhou2014GitHub.txt new file mode 100644 index 0000000000..d9bdb4733a --- /dev/null +++ b/wangzhizhou2014GitHub.txt @@ -0,0 +1,10 @@ +Git is very interesting. + +Thanks for your hardwork that let me mastered a new skill. + +The first time I know the GitHub when I read a book named "Orange S: The implement of an operating system" which written by a Chinese named YuYuan. Then I search on the internet for the new term. Fortunately, I found your tutorial for Git. After one hour reading, I found that I love the powerful software and your style of writing. Thank you again! + +And when I write this letter, you know I will read over your tutorial about git no longer. + +I just want to say: Thank you very much! +I will let more people know your tutorial and you web site. diff --git a/wangzhizhou2014GitHub_2 b/wangzhizhou2014GitHub_2 new file mode 100644 index 0000000000..300fa0adde --- /dev/null +++ b/wangzhizhou2014GitHub_2 @@ -0,0 +1,8 @@ +This is my second time to study your git tutorial, and I reach the topic "Use GitHub" again. +This time I get more knowledge about git not only from your tutorial, but also from a book named "Pro Git". +After compared your tutorial and that book, I still think yours are better, though that book digs deeper in the inner rules that git follow. + +And I decide to read you tutorial the third time after I digest that harder book. +I believe that I will contribute something to your tutorial at that time. +Because I really want to do something to let other people accept git more quickly and widely as well as easily. +At this point, I think we each other can join our hands. diff --git a/wangzihao.txt b/wangzihao.txt new file mode 100644 index 0000000000..6b0ac824a5 --- /dev/null +++ b/wangzihao.txt @@ -0,0 +1,4 @@ +The time is 2015-6-16. +It is the first time to study git and github. +Thank you for liaoxuefeng. +PS: The English is poor.. diff --git a/wdkwdkwdk.txt b/wdkwdkwdk.txt new file mode 100644 index 0000000000..a76aa34ca0 --- /dev/null +++ b/wdkwdkwdk.txt @@ -0,0 +1 @@ +git is useful and fun~ \ No newline at end of file diff --git a/wellstang.txt b/wellstang.txt new file mode 100644 index 0000000000..38b8f4bdab --- /dev/null +++ b/wellstang.txt @@ -0,0 +1 @@ +作为一名git的初学者,这是我读过最简单明了、通俗易懂的入门教程,大赞。 \ No newline at end of file diff --git a/whatit.txt b/whatit.txt new file mode 100644 index 0000000000..ec340dafcb --- /dev/null +++ b/whatit.txt @@ -0,0 +1 @@ +What's it? diff --git a/wideunique.txt b/wideunique.txt new file mode 100644 index 0000000000..b46118e105 --- /dev/null +++ b/wideunique.txt @@ -0,0 +1,2 @@ +hello,I am wideunique!!!!! +thanks for Liao XueFeng!!! \ No newline at end of file diff --git a/wikinee.MD b/wikinee.MD new file mode 100644 index 0000000000..b5a492105f --- /dev/null +++ b/wikinee.MD @@ -0,0 +1,6 @@ +#PULL REQUEST 测试 +以前看到了廖老师的官方网站,之后发现imooc网上还有视屏教程。 +后来找了很久,发现有人把python和git教程都生成了epub的电子书,离线看很好。 +对应mooc网的,我觉得给的提示代码太多了。 +另外,由于有些答案前后会有联系,在后面的答案放上前边的连接,我想会更好。 +谢谢 \ No newline at end of file diff --git a/williamyang.txt b/williamyang.txt new file mode 100644 index 0000000000..941c3b7843 --- /dev/null +++ b/williamyang.txt @@ -0,0 +1 @@ +learn github diff --git a/wind123.txt b/wind123.txt new file mode 100644 index 0000000000..cb3a143171 --- /dev/null +++ b/wind123.txt @@ -0,0 +1 @@ +thank you,liao! diff --git a/wjcccc-Javaer.txt b/wjcccc-Javaer.txt new file mode 100644 index 0000000000..cc37639c40 --- /dev/null +++ b/wjcccc-Javaer.txt @@ -0,0 +1,2 @@ +It`s told by my friend that there`s a blog that teaches git and then I browsed yeaterday,and I found that it was so easy to learn git according to your blog,that is amazing! +I spent 2 days to have a glance at this blog and had known how it worked,thanks to your blog! \ No newline at end of file diff --git a/wjk.txt b/wjk.txt new file mode 100644 index 0000000000..3b18e512db --- /dev/null +++ b/wjk.txt @@ -0,0 +1 @@ +hello world diff --git a/wjlucc.txt b/wjlucc.txt new file mode 100644 index 0000000000..034f16e12a --- /dev/null +++ b/wjlucc.txt @@ -0,0 +1 @@ +跟着廖老师的教程学了下git,非常感谢,教程非常实用,入门很容易,希望廖老师身体健康,工作顺利! diff --git a/wjm3219.txt b/wjm3219.txt new file mode 100644 index 0000000000..8c20aba169 --- /dev/null +++ b/wjm3219.txt @@ -0,0 +1,6 @@ +接触github接近一年了 +之前都是直接在网站上查看源代码和下载编译好的工具用 +一直都没接触到用git工具来对自己fork过的源码进行clone和commit +廖大大的教程写得蛮好,基本熟悉了git与github的关系 +也学会了如何通过git去clone源代码到本地、commit修改后代码至github +非常感谢~ \ No newline at end of file diff --git a/wlkhqc.txt b/wlkhqc.txt new file mode 100644 index 0000000000..7384e930d7 --- /dev/null +++ b/wlkhqc.txt @@ -0,0 +1,3 @@ +Thank you so much,liao. +It's the simplest and useful tutorial I have read,you let me know about git. +Thanks again. diff --git a/wukk.txt b/wukk.txt new file mode 100644 index 0000000000..cd9656b00a --- /dev/null +++ b/wukk.txt @@ -0,0 +1 @@ +i love you!!! \ No newline at end of file diff --git a/wwangaz.txt b/wwangaz.txt new file mode 100644 index 0000000000..af5f38882a --- /dev/null +++ b/wwangaz.txt @@ -0,0 +1,3 @@ +Thank you very much! michaelliao +I learn a lot on you website both on python and git. +And it is my first time donate on the internet just like buy a book. \ No newline at end of file diff --git a/www_elesos_com.cpp b/www_elesos_com.cpp new file mode 100644 index 0000000000..68ddea596e --- /dev/null +++ b/www_elesos_com.cpp @@ -0,0 +1,6 @@ +#include + +int main(){ + printf("hello nice to meet u"); + return 0; +} diff --git a/wwz.txt b/wwz.txt new file mode 100644 index 0000000000..db809f3711 --- /dev/null +++ b/wwz.txt @@ -0,0 +1 @@ +wwz pull request test diff --git a/wyy b/wyy new file mode 100644 index 0000000000..dd62c0a103 --- /dev/null +++ b/wyy @@ -0,0 +1 @@ +testfile wyy diff --git a/wzy-xinde.php b/wzy-xinde.php new file mode 100644 index 0000000000..f582a6bd0a --- /dev/null +++ b/wzy-xinde.php @@ -0,0 +1,6 @@ + diff --git a/wzy.txt b/wzy.txt new file mode 100644 index 0000000000..50c551bc03 --- /dev/null +++ b/wzy.txt @@ -0,0 +1 @@ +可以出书了 \ No newline at end of file diff --git a/xbox360.txt b/xbox360.txt new file mode 100644 index 0000000000..c872184fae --- /dev/null +++ b/xbox360.txt @@ -0,0 +1 @@ +good job! \ No newline at end of file diff --git a/xiangtao_go@163.com b/xiangtao_go@163.com new file mode 100644 index 0000000000..e8e6577231 --- /dev/null +++ b/xiangtao_go@163.com @@ -0,0 +1,2 @@ +Thank your git lession.it is very good for me. +it makes me understand how it work. diff --git a/xiaocunz.txt b/xiaocunz.txt new file mode 100644 index 0000000000..12e30da3e3 --- /dev/null +++ b/xiaocunz.txt @@ -0,0 +1,2 @@ +Through 4 days learn git,I think git is really a good version control system. +Thanks michaelliao for teaching me. \ No newline at end of file diff --git a/xiaofeng.txt b/xiaofeng.txt new file mode 100644 index 0000000000..970ad5ca15 --- /dev/null +++ b/xiaofeng.txt @@ -0,0 +1 @@ +xiaofengfeng hello study \ No newline at end of file diff --git a/xiaofuyesnew.txt b/xiaofuyesnew.txt new file mode 100644 index 0000000000..6db58449ea --- /dev/null +++ b/xiaofuyesnew.txt @@ -0,0 +1,5 @@ +非常感谢廖老师的git教程,让我从一个git的门外汉在短短两天时间里面学会怎么使用git。 +虽然现在我的IT知识还很有限,但是我还是希望通过自己的努力成为像廖老师一样的IT达人。 +还有很多不懂的问题,还要向廖老师学习。我相信一定能做到。 +谢谢廖老师给我们提供了一个实际操作的平台。 +xiaofuyesnew 2015年1月4日 diff --git a/xiaoke040.markdown b/xiaoke040.markdown new file mode 100644 index 0000000000..d550cf7559 --- /dev/null +++ b/xiaoke040.markdown @@ -0,0 +1,10 @@ + +非常抱歉 +默认是ANSI编码 +嗯哼,我再找找详细的教程看看 +昨天学的东西又忘了 + + +===== +做新手教程很好,还在学习中 +还是不太熟悉啊 diff --git a/xiaoshan.txt b/xiaoshan.txt new file mode 100644 index 0000000000..364d384e1c --- /dev/null +++ b/xiaoshan.txt @@ -0,0 +1 @@ +Thank you teacher Liao! \ No newline at end of file diff --git a/xinghun.txt b/xinghun.txt new file mode 100644 index 0000000000..9e7e1bffce --- /dev/null +++ b/xinghun.txt @@ -0,0 +1,3 @@ +的确是很不错的一篇教程,看过的Git教程中最好的一篇了。 +之前看其他教程看一小会就看不下去了,所以也一直没学会Git。 +今天看了一上午这个教程,终于学会Git了。 \ No newline at end of file diff --git a/xiniu.txt b/xiniu.txt new file mode 100644 index 0000000000..4144bdccae --- /dev/null +++ b/xiniu.txt @@ -0,0 +1,17 @@ +花了两天时间,阅读了廖雪峰先生的整个教程,对Git以及GitHub有了 +基本的了解,掌握了一些Git的常用操作。写了一下新得与体会,顺便 +实验下pull request操作: +1.Git是一个分布式的版本控制系统,GitHub是一个开放式的代码托管 +平台; +2.我们可以在GitHub上fork一个项目,然后在个人PC上为该项目修改和 +贡献代码,最后通过pull request操作请求项目的拥有者添加进去你的 +代码; +3;Git的命令行控制方式和Linux系统很像啊; +4暂存区的概念很重要,可以帮你理解“git add”和‘git commit’操作; +5分支的优越性:我们通常只把自己的改写合并到dev上,而不是master; +这样做既可以使各开发者工作互不干扰,能够随时提交,还能维护已发 +布的最新版本; +6个人感觉checkout 这个命令很容易混淆: + eg:git checkout -- readme.txt //撤销工作区的修改 + git checkout -b dev //新建了一个分支dev,并跳转到该分支 + git checkout master //重新回到主分支 \ No newline at end of file diff --git a/xiongmaozhijin.txt b/xiongmaozhijin.txt new file mode 100644 index 0000000000..862acec053 --- /dev/null +++ b/xiongmaozhijin.txt @@ -0,0 +1 @@ +谢谢,通过该教程对Git的使用有了了解。 \ No newline at end of file diff --git a/xixixiix.txt b/xixixiix.txt new file mode 100644 index 0000000000..0524994ec5 --- /dev/null +++ b/xixixiix.txt @@ -0,0 +1 @@ +thx,xixiixixixi \ No newline at end of file diff --git a/xrfinbupt.txt b/xrfinbupt.txt new file mode 100644 index 0000000000..d3df1f8ab3 --- /dev/null +++ b/xrfinbupt.txt @@ -0,0 +1,8 @@ + +1 谢谢你结合案例把git的用法讲的很清楚 + +2 让我清晰的知道git与SVN的区别 + +3 记住了git的index概念,分支的细节 + +4 下一次我一定把你写的Python看一下,thx from 校友 diff --git a/xunyl.txt b/xunyl.txt new file mode 100644 index 0000000000..b0c8225806 --- /dev/null +++ b/xunyl.txt @@ -0,0 +1,4 @@ +Thank you so much for your course! + +by xunyl +2015-4-5 Sun. diff --git a/xxxxx.txt b/xxxxx.txt new file mode 100644 index 0000000000..8789985471 --- /dev/null +++ b/xxxxx.txt @@ -0,0 +1 @@ +xxxxxx \ No newline at end of file diff --git a/yangshuo.txt b/yangshuo.txt new file mode 100644 index 0000000000..74cd769ccd --- /dev/null +++ b/yangshuo.txt @@ -0,0 +1,5 @@ +At first thanks Mr. Liao very much. Your course is the best one after I have saw many courses about git. +I just want to tell the other people who want to learn git that you just need to use less than 5 hours and follow the course step by step you won't afraid of git anymore! + +test! + diff --git a/yccphp@163.com b/yccphp@163.com new file mode 100644 index 0000000000..184e35208a --- /dev/null +++ b/yccphp@163.com @@ -0,0 +1,252 @@ + + + +git init + 命令把这个目录变成git 可以管理的仓库 + +git add 文件名 + 把文件添加到仓库 + + +git status + git 仓库的状态 + + +git commit -m "add readme.text file” + + 把文件提交到仓库 + + -m 是本次的提交说明 + +git diff readme.txt + + 查看文件修改内容 + +git log + 查看版本提交记录 + + --pretty=oneline 只显示版本号和提交注视 + + +在 git 中,当前版本用 HEAD 表示,上一个版本是 HEAD^ ,上上个版本是 HEAD^^ + +往上 100 个版本就是 100 个 ^ ,难写,所以写成 HEAD~100 + + +git reset --hard HEAD^ + + 回到上一个版本 + +git reset --hard eb7378897e8996f1e + + 根据版本号回到此版本 + +git reflog + + 查看每一次的版本id + +git diff HEAD -- readme.txt + + 查看工作区与版本库里面的文件区别 + + + + + + +git checkout -- readme.txt + + 把 readme.txt 文件在工作区的修改全部撤销 + + 1、如果文件修改后,还没有放到暂寸区,撤销后,和版本的一样 + 2、如果文件已经放到暂存区,撤销户,回到暂存区的状态 + + +git reset HEAD readme.txt + + 把暂存区的文件撤销掉,重新放回工作区 + + +git rm test.php + + 删除版本库里面的文件,需要再次 commit + + + + + +生成 ssh key + + ssh-keygen -t rsa -C “youremail@example.com" + + 一路默认 + + /Users/yuanchao/.ssh 里面保存了生成的 key .pub 是公钥 + + + + +添加远程仓库 + + 在 git 新建一个仓库 + + 把这个仓库与本地仓库关联 + git remote add origin git@github.com:yccphp/testgit.git (每个仓库不同) + + + 把我们本地仓库的所有内容推送到远程库 + git push -u origin master (第一次) + + 以后每次提交 + git push origin master + + + + + + + + + +从远程仓库克隆 + + + git clone git@github.com:yccphp/gitclonetest.git + + 不同的 git 不同的地址 + + 然后修改后,需要推送的话,还是使用推送命令 push + + +创建合并分支 + + + checkout -b 分支名 + + -b 表示创建并且切换 + +git branch 分支名 + + 创建一个分支 + + +git checkout 分支名 + + 切换到某个分支 + +git branch + + 查看当前分支 + + + +git merge dev + + 合并指定分支 到当前分支上 + +git branch -d dev + + 删除指定分支 + + +git log --graph --pretty=oneline -—abbrev-commit + + 查看分支合并情况 + + +git merge --no-ff -m "merge with on-ff" dev + + 合并创建一个新的提交 + + —no-ff 普通合并,合并后的历史有分支,能看的出来曾经做过合并 + + + + +bug 分支 + +当你接到一个修复一个代号101的bug的任务时,很自然地,你想创建一个分支issue-101来修复它,但是,等等,当前正在dev上进行的工作还没有提交: + + + +git stash + + 将当前工作区储存起来,等恢复以后继续工作 + + +git stash pop + 将存储起来的内容,恢复 + + +强行删除分支 + git branch -D feature-vulcan + + 如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 + + + +git remote + + -v 显示更详细的信息 + + 查看远程分支的信息 + + + + +标签 + + + +切换到需要打标签的分支上 + + +git tag + + 打一个新的标签 标签名 + +git tag + + 查看所有标签 + + +git tag v789 7a7e436 + + 根据某个提交id ,打新的标签 + +git show v789 + 查看标签信息 + + +git tag -a dev1.0 -m “开发版" + + -a 标签名 + -m 说明 + + +git tag -d + + 删除标签 标签名 + + +git push origin v1.0 + + 推送标签到远程服务器 + + +git push origin —tags + + 推送本地所有未推送的标签 + + +删除远程服务器上面的标签 + +1、先从本地删除 + + git tag -d v789 + +2、删除远程上的tag + + git push origin :refs/tags/v0.9 + + diff --git a/ymjrcc.txt b/ymjrcc.txt new file mode 100644 index 0000000000..e1a5de878a --- /dev/null +++ b/ymjrcc.txt @@ -0,0 +1,3 @@ +正在同时学习廖老师的 git 教程和 js 教程。感觉廖老师讲得非常清晰明了,让我受益匪浅,谢谢廖老师! + +学习 git 最大的感受就是:git 真是提高效率的神器啊!我会继续学习的,努力提高姿势水平,加油,哈哈! diff --git a/your-github-enhedalai.txt b/your-github-enhedalai.txt new file mode 100644 index 0000000000..9cc39d95a2 --- /dev/null +++ b/your-github-enhedalai.txt @@ -0,0 +1 @@ +git diff --git a/your-github-id.txt b/your-github-id.txt new file mode 100644 index 0000000000..66dcf50ac9 --- /dev/null +++ b/your-github-id.txt @@ -0,0 +1,8 @@ +一口气全部看完了,讲得很详细很有黑皮书的感觉。硬是要说缺点的话就是github的多人合作介绍得不够具体。 +我对github上的协作是这样理解的:fork就好比转载别人的文章,因为不转载是没有权限修改的。而转载后在自己的地盘想怎样就怎样。然后要把别人的文章下载到自己电脑上修改,这个就是clone。在自己电脑上修改完成后保存就是git add和git commit。想要发表到网上就是git push。发表了想让作者添加你的修改就得向作者提交请求,让作者知道你改了什么,这个就是pull request +//工作区,缓存区,仓库和github这些还没想到比较好的比喻 +//用了your-github-id.txt这个文件名一定会被拒绝吧= = +thank you very much!!! +直接在your-github-id.txt中修改,然后推送一下看看我的内容有没有推送成功,哈哈!From:mailtohwj@gmail.com。 +test +教程非常赞,我试试能不能pull? diff --git a/your-github-whatswhat.txt b/your-github-whatswhat.txt new file mode 100644 index 0000000000..b3e404237a --- /dev/null +++ b/your-github-whatswhat.txt @@ -0,0 +1,189 @@ + + + + + +$ git init 初始化一个Git仓库 + +添加文件到Git仓库,分两步: +$ git add +$ git commit -m "....." + +$ git status + +$ git diff #比较工作区和暂存区文件差异 (Working Directory工作区(add操作前) 和 stage暂存区(add操作后) 的区别) +$ git diff HEAD -- 查看工作区和版本库里面最新版本的区别(Working Directory工作区(add操作前) 和 Repository版本库(commit操作后) 的区别) + + +版本回退: +$ git reset --hard +$ git reset --hard HEAD^ +首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交3628164...882e1e0(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。 + + +$ git log 查看提交历史 +$ git log --pretty=oneline + +$ git reflog 查看命令历史 + + + * +HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 + * +穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 + * +要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本 + + + +撤销修改: +$ git checkout -- readme.txt 把readme.txt文件在工作区的修改全部撤销 丢弃工作区的修改 +一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态; +一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。 +总之,就是让这个文件回到最近一次git commit或git add时的状态。 + +$ git reset HEAD file 把暂存区的修改撤销掉(unstage),重新放回工作区 + + +场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。 +场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。 +场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。 + +远程仓库 +$ git push -u origin master +$ git push origin master + + +要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git; +关联后,使用命令git push -u origin master第一次推送master分支的所有内容; +此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改; + +从远程库克隆: +$ git clone git@github.com:whatswhat/gitskills.git 后面是仓库的地址 ssh(速度快) +$ git clone https://github.com/whatswhat/gitskills.git 后面是仓库的地址 http + +分支管理 +创建与合并分支 + + +查看分支:git branch +创建分支:git branch +切换分支:git checkout +创建+切换分支:git checkout -b +合并某分支到当前分支:git merge +删除分支:git branch -d +解决冲突、分支管理策略 +用git log --graph命令可以看到分支合并图 +$ git log --graph --pretty=oneline --abbrev-commit + + + +通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。--no-ff方式的git merge: 准备合并dev分支,请注意--no-ff参数,表示禁用Fast forward: +$ git merge --no-ff -m "merge with no-ff" dev + + +Bug分支 +Git还提供了一个stash功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作: +$ git stash +$ git stash list + + +工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法: +一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除; +另一种方式是用git stash pop,恢复的同时把stash内容也删了: +$ git stash apply + +$ git stash pop + + + +你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,用命令: + +$ git stash apply stash@{0} + + + +小结 +修复bug时,我们会通过创建新的bug分支进行修复,然后合并,最后删除; +当手头工作没有完成时,先把工作现场git stash一下,然后去修复bug,修复后,再git stash pop,回到工作现场。 + +Feature分支 + +开发一个新feature,最好新建一个分支; +如果要丢弃一个没有被合并过的分支,可以通过git branch -D 强行删除。 + +多人协作 + + +当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应起来了,并且,远程仓库的默认名称是origin。 +$ git remote 查看远程库的信息 +$ git remote -v 显示更详细的信息(显示可以抓取fetch和推送push的origin的地址) + +推送分支 +推送分支,就是把该分支上的所有本地提交推送到远程库。推送时,要指定本地分支,这样,Git就会把该分支推送到远程库对应的远程分支上: +$ git push origin master +如果要推送其他分支,比如dev,就改成: +$ git push origin dev + +并不是一定要把本地分支往远程推送,那么,哪些分支需要推送,哪些不需要呢? + + * +master分支是主分支,因此要时刻与远程同步; + * +dev分支是开发分支,团队所有成员都需要在上面工作,所以也需要与远程同步; + * +bug分支只用于在本地修复bug,就没必要推到远程了,除非老板要看看你每周到底修复了几个bug; + * +feature分支是否推到远程,取决于你是否和你的小伙伴合作在上面开发。 + +总之,就是在Git中,分支完全可以在本地自己藏着玩,是否推送,视你的心情而定! + +抓取分支 +$ git checkout -b dev origin/dev 创建远程origin的dev分支到本地 +$ git branch --set-upstream dev origin/dev 设置本地dev分支与远程origin/dev分支的链接 +$ git pull 把最新的提交从远程origin/dev抓下来 + + +多人协作的工作模式通常是这样: + + 1. +首先,可以试图用git push origin branch-name推送自己的修改; + 2. +如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; + 3. +如果合并有冲突,则解决冲突,并在本地提交; + 4. +没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! + +如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。 + + +小结 + + * +查看远程库信息,使用git remote -v; + * +本地新建的分支如果不推送到远程,对其他人就是不可见的; + * +从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交; + * +在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致; + * +建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name; + * +从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。 + + +标签管理 +创建标签 +$ git tag 新建一个标签(需先切换到要打标签的分支上)(默认为HEAD,也可以指定一个commit id) +$ git tag -a -m "…" 指定标签信息 +$ git tag -s -m “…" 用PGP签名标签(如果报错,请参考GnuPG帮助文档配置Key。) +$ git tag 查看所有标签 +$ git show 查看标签信息 + +操作标签 +$ git tag -d 删除一个本地标签 +$ git push origin 推送一个本地标签 +$ git push origin --tags 一次性推送全部未推送到远程的本地标签 +$ git push origin :refs/tags/ (从远程删除)删除一个远程标签(需先从本地删除即先执行git tag -d 命令) diff --git a/your_github-charliecen.txt b/your_github-charliecen.txt new file mode 100644 index 0000000000..3cd3ed3d2c --- /dev/null +++ b/your_github-charliecen.txt @@ -0,0 +1,7 @@ +第一次真正全面看git教程,简洁而容易理解。对新手的我来说帮助很大。 + +俺现在生产环境还在用svn,看来是不是该丢了。嘿嘿! + +看完一次再看第二次理解会更深刻。 + +谢谢大神的git教程。 diff --git a/youshihou.txt b/youshihou.txt new file mode 100644 index 0000000000..b88c055cad --- /dev/null +++ b/youshihou.txt @@ -0,0 +1,9 @@ +#include + +int main() +{ + printf("hello git"); + + return 0; + +} diff --git a/youzi.txt b/youzi.txt new file mode 100644 index 0000000000..35539714d0 --- /dev/null +++ b/youzi.txt @@ -0,0 +1 @@ +博主实在是太酷了,真的是设身处地的以初学者的思维写就博客的.博主让我对以前一点不感兴趣的编程产生了浓厚的兴趣.真的是万分感谢,我会时不时的小额资助博主的. diff --git a/yoyoyo.txt b/yoyoyo.txt new file mode 100644 index 0000000000..7315c41cdc --- /dev/null +++ b/yoyoyo.txt @@ -0,0 +1 @@ +真是不错的教程呢? 看着根本停不下来 现在都晚上3点了 - - 棒棒哒 \ No newline at end of file diff --git a/ysfox.txt b/ysfox.txt new file mode 100644 index 0000000000..96aeaef57f --- /dev/null +++ b/ysfox.txt @@ -0,0 +1 @@ +Tanks... diff --git a/yutiya.md b/yutiya.md new file mode 100644 index 0000000000..b4df98cc87 --- /dev/null +++ b/yutiya.md @@ -0,0 +1,12 @@ +看了你的git教程,学会了很多东西 +不过很快就忘了,呵呵 +不多常用的还是都记住了 +现在一般的抓取合并创建分支都能搞定 +git的理念非常不错,所以喜欢上了他 +看到这么多写文档,就为了pull request 的 +本来想开两个账号的,现在直接找您试试 +因为git爱上了github,因为github爱上了Markdown +我是第一个用md文件提交的吧 +祝阖家欢乐 + +**谢谢** \ No newline at end of file diff --git a/zb-basketball.txt b/zb-basketball.txt new file mode 100644 index 0000000000..e3c36ab6cc --- /dev/null +++ b/zb-basketball.txt @@ -0,0 +1,6 @@ + +Hello, 3Q for your git guide. + + +this is just a test for "pull request"! + diff --git a/zb1717.txt b/zb1717.txt new file mode 100644 index 0000000000..5b521b1b7f --- /dev/null +++ b/zb1717.txt @@ -0,0 +1 @@ +shou yi fei qian diff --git a/zhanba.txt b/zhanba.txt new file mode 100644 index 0000000000..c8bb1f5ce5 --- /dev/null +++ b/zhanba.txt @@ -0,0 +1,2 @@ +pull request! +Great job!Thank you! \ No newline at end of file diff --git a/zhangdongwei.txt b/zhangdongwei.txt new file mode 100644 index 0000000000..b1ddcd073c --- /dev/null +++ b/zhangdongwei.txt @@ -0,0 +1 @@ +您讲的Git太好了,必须支持! diff --git a/zhangjia517_Rename.txt b/zhangjia517_Rename.txt new file mode 100644 index 0000000000..c41885994e --- /dev/null +++ b/zhangjia517_Rename.txt @@ -0,0 +1 @@ +测试下是否支持中文的文件名 谢谢廖老师! \ No newline at end of file diff --git a/zhangkaichuang.cpp b/zhangkaichuang.cpp new file mode 100644 index 0000000000..486059025a --- /dev/null +++ b/zhangkaichuang.cpp @@ -0,0 +1,8 @@ +#include + +using namespace std; + +int main() +{ + cout << "this is a good course for git. thank you" << endl; +} diff --git a/zhanglintc.txt b/zhanglintc.txt new file mode 100644 index 0000000000..71a0cd05b8 --- /dev/null +++ b/zhanglintc.txt @@ -0,0 +1,3 @@ +一直想测试一些pull request功能,找不到我能够参与的项目。 +只好到这里来参与了。 +请一定要同意我的pull request啊! :D \ No newline at end of file diff --git a/zhangrunbsm.txt b/zhangrunbsm.txt new file mode 100644 index 0000000000..d810ceb8e9 --- /dev/null +++ b/zhangrunbsm.txt @@ -0,0 +1 @@ +Thanks for your course. It's really helpful. \ No newline at end of file diff --git a/zhangyan.txt b/zhangyan.txt new file mode 100644 index 0000000000..1f0d08b52a --- /dev/null +++ b/zhangyan.txt @@ -0,0 +1 @@ +Thank you for your tutorial,Michael! \ No newline at end of file diff --git a/zhaoml529 b/zhaoml529 new file mode 100644 index 0000000000..f2270334b0 --- /dev/null +++ b/zhaoml529 @@ -0,0 +1 @@ +一直自己用,没有试过Pull request,现在试试。 diff --git a/zhaoxinyu.txt b/zhaoxinyu.txt new file mode 100644 index 0000000000..d9d8ec9ad0 --- /dev/null +++ b/zhaoxinyu.txt @@ -0,0 +1,3 @@ +Git is an awesome version control system. +I want to use it well. +Thank you for writing such a useful tutorial. diff --git a/zhouzhou.txt b/zhouzhou.txt new file mode 100644 index 0000000000..f206dc72ef --- /dev/null +++ b/zhouzhou.txt @@ -0,0 +1,2 @@ + +I'm a master student in ZJU.Thank you for your work very much. diff --git a/zhuqiao1018.txt b/zhuqiao1018.txt new file mode 100644 index 0000000000..df961a0b49 --- /dev/null +++ b/zhuqiao1018.txt @@ -0,0 +1 @@ +很好的git教程!感谢作者 \ No newline at end of file diff --git a/zk416605134@163.com.txt b/zk416605134@163.com.txt new file mode 100644 index 0000000000..087bf5b0ee --- /dev/null +++ b/zk416605134@163.com.txt @@ -0,0 +1 @@ +thank you sir for your help! \ No newline at end of file diff --git a/zongyl.txt b/zongyl.txt new file mode 100644 index 0000000000..e9baf1bcd2 --- /dev/null +++ b/zongyl.txt @@ -0,0 +1,97 @@ + + +hello,Mr Liao! Your tutorial is very good, So I learned quickly, Please receive my first pull request. thanks! +====================================================================== +git init 创建git仓库 + +git status 查看当前状态 + +git add 添加文件到缓冲区 + +git commit -m "..."提交 + +git diff 对比文件 + + +git log 命令显示从近到远的提交日志 + +git log --pretty=online 格式化 + +版本退回 +HEAD 表示当前版本 +HEAD^ 表示上一个版本 +HEAD^^ 表示上上个版本 +HEAD~n 表示上n个版本 + +git reset --hard HEAD^ + +git reset --hard 1111111 退回到指定的版本 1111111表示commit id + +git reflog 显示命令执行历史 + +git checkout -- 撤销工作区的修改。 + +git reset HEAD file 撤销已经add的修改。 + +删除文件 +rm 从本地删除文件 + +git -rm 删除版本库中的文件 + +远程仓库 + +关联远程仓库 git默认为origin +git remote add origin git@github.com:zongyl/learngit.git + +把当前分支master推送到远程。第一次推送远程,加上-u参数,可以将本地的master 和远程的master分支关联起来。 +以后的推送或者拉去可以简化命令。 +git push -u origin master + +git push origin master 提交到远程。 + +从远程克隆到本地 +git clone git@github.com:zongyl/learngit.git + +git支持多种协议,默认的git://使用shh,但也可以用https等其他协议。 git协议速度最快。 + +分支管理 + +git checkout -b dev --创建并切换到dev分支上 +-b 表示创建并切换,相当于以下两条命令 +git branch dev +git checkout dev + +git branch ---列出所有分支,带*号的为当前分支 + +git merge dev ---合并指定分支(dev)到当前分支。 + +git branch -d dev ---删除分支 + +git log --graph ---查看分支合并图。 + + +分支合并时,git默认使用fast forward模式。删除分支后,会丢掉分支信息,看不出做过合并。 + +git merge --no--ff dev 合并分支,禁用fast forward 模式。 + + + + + + + + + + + + + + + + + + + + + + diff --git a/zouyiran.txt b/zouyiran.txt new file mode 100644 index 0000000000..bbf86906a3 --- /dev/null +++ b/zouyiran.txt @@ -0,0 +1 @@ +I have a better understanding about git & github after I visit your website,thank you so much. \ No newline at end of file diff --git a/zpcandzhj.txt b/zpcandzhj.txt new file mode 100644 index 0000000000..855becf1f6 --- /dev/null +++ b/zpcandzhj.txt @@ -0,0 +1,6 @@ +老师的教程很不错! +我们学生缺少项目开发经验,老师要是能够结合一个案例细致地讲述一下企业项目开发 +到底是怎么进行版本控制的,大家怎么合作的,讲的稍微完整细致一点就锦上添花了! +O(∩_∩)O谢谢老师的教程!! + +鸟鹏 2014.11.19 \ No newline at end of file diff --git a/zwq58.txt b/zwq58.txt new file mode 100644 index 0000000000..36c85c3654 --- /dev/null +++ b/zwq58.txt @@ -0,0 +1,2 @@ +sonack!! +Thank you very much !! \ No newline at end of file diff --git a/zxae86.txt b/zxae86.txt new file mode 100644 index 0000000000..595ec4854a --- /dev/null +++ b/zxae86.txt @@ -0,0 +1 @@ +谢谢 好人一生平安! \ No newline at end of file diff --git a/zzhblh.txt b/zzhblh.txt new file mode 100644 index 0000000000..1f0d08b52a --- /dev/null +++ b/zzhblh.txt @@ -0,0 +1 @@ +Thank you for your tutorial,Michael! \ No newline at end of file diff --git a/zzy_learngit b/zzy_learngit new file mode 100644 index 0000000000..8204c8d83d --- /dev/null +++ b/zzy_learngit @@ -0,0 +1 @@ +刚开始学习github,请多多关照! diff --git a/zzz.txt b/zzz.txt new file mode 100644 index 0000000000..1fb207d474 --- /dev/null +++ b/zzz.txt @@ -0,0 +1 @@ +I love ppppython \ No newline at end of file