zoukankan      html  css  js  c++  java
  • git使用笔记

    本篇记录自己使用git的问题:

    git中的repository的意思是仓库,就相当于一个文件夹。刚建立的新的repository自带一个master的分支,你也可以新建别的分支(拷贝),分支branching的意思就是you’re making a copy, or snapshot, of master,方便某个人想在主干master版本上修改,但他在分支上的修改不会影响到主干或者别的分支;如果主干master上的内容在自己修改分支这段时间内改变了,分支上的可以pull in those updates.

    git中的commit的意思是make changes,On GitHub, saved changes are called commits. Each commit has an associated commit message, which is a description explaining why a particular change was made. Commit messages capture the history of your changes, so other contributors can understand what you’ve done and why.

    git中的pull的翻译是拉取: Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch. Pull requests show diffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red.拉取请求是GitHub上协作的核心。当您打开一个请求时,您提出了您的更改,并请求有人检查和拉入您的贡献并将其合并到他们的分支中。拉取请求显示来自两个分支的内容的差异。更改、添加和减法显示为绿色和红色。

    使用Git Bash上传内容到Gitlab

    1. 初次操作

    如同链接中的4,-11步骤。https://blog.csdn.net/liguangxianbin/article/details/80389377

    2. 日常操作

    2.1. 首先创建了20.2.3.mm文件,然后git add 20.2.3.mm. 使用git add 文件名,命令行将文件保存到暂存区。

    2.2. 主要是commit(保存更改),git commit -m "002commit";输入git commit -m 备注信息 命令将文件提交到本地仓库。

    2.3. 主要是push(上传更改),git push origin master;

    Gitlab

    之前只有用git clone 'git_url'来下载别人的项目过,但是这两天自己创建了第一个项目,代码托管在gitlab(类似于github的另外一个代码托管)上。

    0.一开始肯定是注册账号,注册gitlab账号始终不成功,总是提示密码设置的问题,百度后有人说点击登录sign in(不是注册sign up)那里,点击github账号登录,也就是说有了github后就可以自动生成一个一样的gitlab账号了。不过这种方式第一次登录gitlab后,需要设置密码(因为省掉了注册这一过程来提供密码)。

    随后就是在网页上点击按钮,create new project,生成第一项目,注意:项目名称不能是中文!(有一定的字符要求)权限可以设置为private。

    1. 给gitlab添加公钥,参考https://www.cnblogs.com/xiuxingzhe/p/9303278.html

    2.使用git bash来进行上传自己的项目,参考https://blog.csdn.net/M1026/article/details/52184124https://www.cnblogs.com/lil-Xing/p/11405192.html

     

     

     

     3. git查看信息

     输入ssh -T git@github.com测试ssh连接github。

    3.当你需要更新项目时,该怎么办?还是与上面第一次提交代码时一样吗?应该是不一样的,我用了步骤1一样的代码,结果碰到的问题是hint:Updates were rejected because the tip of your current branch is behind its remote counterpart.....等等好几行错误提示,后来我尝试多种方法无果,只得采取新增一个分支branch的做法,然后象初次上传一样,将最新的本地仓库push到新的branch中。新增一个分支branch可参考https://www.cnblogs.com/code-changeworld/p/4779145.html第三条。

    问题1: 如何merge两个branch?如下图有master和second两个branch。

    merge request按钮,继续之后最终将新分支中的内容合并到旧的分支中去。

    Gitlab使用教程此处还有在Eclipse中使用gitlab的详细操作教程。

    学习是熵减的过程,终身学习应当是每个人去做到的。
  • 相关阅读:
    二叉树——Java实现
    Java实现单链表的增删查改及逆置打印
    常见排序——Java实现
    [导入]Interesting Finds: 2007.12.10
    [导入]Interesting Finds: 2007.12.09
    [导入]Interesting Finds: 2007.12.12
    [导入]Interesting Finds: 2007.12.06
    [导入]Interesting Finds: 2007.12.07
    [导入]Interesting Finds: 2007.12.04
    [导入]Interesting Finds: 2007.12.05
  • 原文地址:https://www.cnblogs.com/alesvel/p/10116577.html
Copyright © 2011-2022 走看看