One of my git (code cloud) Tour

Cooperative development projects, you will use git, now code cloud is relatively simple, because it is a cultural interface, the learning curve is relatively low degree of difficulty, but also supports the five following items free, so better start learning code a little cloud.

The following are a few basic things for relatively low users to learn, because I was ah. . . I have friends with pictures, encourage each other.

(1) I now want to use it, create a folder mayunDemo, cut a memorial to commemorate the map.

 

(2) I have a cloud registration code, registration is a prerequisite to work, you go to register a first. . .

  URL for you: https://gitee.com

(3) you have registered one yard cloud account it!

  Click on the top right of the individual user, you enter the user interface, you need an SSH public key, it does not generate a public key.

  Use SSH public key allows you to use a secure connection when your PC and the cloud communications code (Git to use the Remote SSH address).

 

 

 (4) generate a public key, people have prompted you, I give you just cut a figure!

  . . . Think carefully, forget it, screenshots you are too lazy to cut.

(5) because the problem I need, so first pay deleted. . .

 

My Ma. . . Cloud yards, warehouses, view your inventory. . . Then of course, point to open it slightly!

 

 Click management, access management interface

 

 Tip accordance with the process step by step removed. . . The coefficient of difficulty is not high, please practice on their own.

Delete the warehouse when repeatedly reminded, repeated verification, very humane.

Here first cut for the King!

(6) now begin to create the warehouse! You should be aware of the following operations, as mentioned above, a warehouse, a warehouse you click New on the line.

To play on their own to build a private.

 

 Code repository cloud will bring their copies, on the use of performance optimization (ha ha, I shot in the dark), the amount,

 

 

 It is strongly recommended that you carefully read these few lines of code to set up users and mailboxes, will be back for the identification a lot of things.

(7) to find a folder, right-blank, open your git (much like the black cmd window)

 

 

 Nani? you have not. . . My God

Well, make up a git installation, point to open their own look.

(8) To be honest, I have enough strength, are reference materials

We want to modify the warehouse documents, it is not it should first download a copy of it. . .

https://www.oschina.net/question/82993_133520

这个网址,是官网带的连接博客,名叫 “ 如何导入外部Git仓库到中国源代码托管平台(Git@OSC)”,

名字威武霸气,提供了3中情况下的导入方案。

我们实践第一种,其他的我也不会撒。

git clone --bare  https://github.com/bartaz/impress.js.git (例子)

 

 他说我克隆了一个空仓库,我丢~

于是乎,我把他提示的代码,就是几行简单的入门命令,输了一次。。。

好吧,错的东西即使翻译之后也不知道怎么该,尝试最后两行代码。。。

我往mayunDemo里面放了一个文件,然后我的编译器后面出现了一个绿色的u

 

 除非你上传了改变,这个u才会消失,但是暂时只能这样。。。不甘呀。。。

(9)那就提交呗。。。查资料,怎么提交呢?

1 提交代码:
2 1) git add .     
3 2)git commit -m "分支名"  
4 3)git push  (如果有代码冲突,先git pull 在git push)

 

 我们直接打开还没有操作的库,所在的分支就是master,因为你git clone克隆的分支就是默认分支。

下面介绍以下git add

git add -A和 git add . git add -u在功能上看似很相近,但还是存在一点差别

git add . :他会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文件内容修改(modified)以及新文件(new),但不包括被删除的文件。

git add -u :他仅监控已经被add的文件(即tracked file),他会将被修改的文件提交到暂存区。add -u 不会提交新文件(untracked file)。(git add --update的缩写)

git add -A :是上面两个功能的合集(git add --all的缩写)

(10)好了,更新库的绿帽子已经没有了!

 

这个黄点点是啥呢?

绿色,已经加入控制暂未提交
红色,未加入版本控制
蓝色,加入,已提交,有改动
白色,加入,已提交,无改动
灰色:版本控制已忽略文件。

 

 这里显示我们已经提交上去了!而界面上呢,许多功能因为你的库的存在,可以使用了!

(11)早上好!又到了博客凑字数时间!

 好了,我们进入昨天的文件,进去之后呢,直接就进入了master分支

 我们查看分支git branch

 

 

 (12)分支的意义

分支对于团队来说作用太大了。比如说一个项目现在是1.0版,那么开发团队可能要同时进行1.1版和2.0版的开发,这样代码就会出现较大分歧。这时候就需要用到分支了,不同的任务组在不同的分支上开发,互相之间不会影响。再比如说,需要向项目中添加一个新功能,一般的团队都不会直接在主分支上修改,都会新建一个分支,在上面更改代码。这样做的好处就是保证主线代码的完整性和可用性,也就是说,主线上都是稳定的代码,可以直接拿来发布的。

再说说分支在GIT上的特点:GIT的技术可以说是非常强大,说一切开发都依赖于分支一点都不过分。一般项目的master分支都是稳定的代码,可以直接发布或者被项目之外的人使用。新特性和BUG修改都在不同的分支上进行开发和测试。这样规范了整个软件的开发流程。分支之间的互不影响这种特性可以增加团队合作的效率。GIT分支的另外一个重要特性就是可以合并不同软件仓库(fork)的分支。大体就是:开发团队有一个主软件仓库,开发者可以fork这个仓库,相当于克隆了一个私有的软件仓库,然后开发者就可以在自己的软件仓库中建立分支并开发测试,测试完毕之后,可以向主软件仓库提交merge request,这样新开发的特性就会被合并到主软件仓库的某个分支中。这种特性极大地推动了开源项目,多年前参加开源项目都是神话,自从GIT出现后,每个人都可能成为开源项目的贡献者,就是基于这种特性(请参照Github的pull request,和merge request是同一个东西)。

(13)新建一个本地分支  :  git branch 分支名

 

 

 新建一个本地分支newDemo,然后查看,嗯啊,就有啦

(14)切换分支  : git checkout  分支名

 

 

 切换本地分支newDemo,下面一行代码最后分支显示我们切换了分支。

Git checkout 分支名,执行后,你本地的数据,,目录结构,都会自动更新成该成员的分支的内容我又新建了一个分支,修改了其中一条,但是呢,如果添加了一个文件,没有add的话,git会不动

 (16)合并分支。。。:git merge 分支名

 

 

 合并之后,newDemo2还在。

(17)删掉他!。。。删除本地分支:   git branch -D 分支名

 

 

 好了,nbewDemo2删除掉了。

(18)我们查看码云界面,你修改本地不会引起远程服务器的改变

 

 

 推送一下远程就好了。

(19)代码有冲突,就需要下拉,这里不演示了,等项目遇到说。

提交代码:1) git add . 2)git commit -m "分支名" 3)git push (如果有代码冲突,先git pull 在git push)
(20)git 回退到某个历史版本: git reset --hard 1123123bbb9c00bbdca96(分支ID)

 

 

 


(21)、修改推到远程服务器:git push -f -u origin 分支名

  总结:反正就这么下来了,一边研究一边敲,输出式学习比输入式学习强太多,以后做作业用git简单提交下,慢慢熟悉,慢慢看bug。

Guess you like

Origin www.cnblogs.com/GGbondLearn/p/12271356.html