-2、pull by url

git remote set-url origin --push --add user1@repo1
git remote set-url origin --push --add user2@repo2
git remote -v

-1、gitlab使用:

ssh-keygen -t rsa -C "your_email@unisound.com"

可以在用户主目录里找到.ssh目录,里面有id_rsaid_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。

登陆 Gitlab,在『User Settings』→『SSH Keys』页面,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容,保存。

本地 git 安装后,需要设置用户名和email:

$ git config --global user.name "Your Name"
$ git config --global user.email "your_email@unisound.com"

0、配置git使用代理的问题

注意查看ss的socket设置

然后编辑

git config --global http.proxy socks5://127.0.0.1:1086
git config --global https.proxy socks5://127.0.0.1:1086
可以查看
.gitconfig文件

1、merge以后查看diff

git 做了 merge的时候,比如 当前分支是 dev,需要merge rls的代码

git pull origin rls

做完merge以后,形成了3份代码:新代码、dev原来的代码、rls的代码,需要比较新代码和 dev原代码的不同,也要比较 新代码和 rls的区别

git  diff dev

git diff rls

2、merge的时候希望pom文件必选按照某个的

如果做了 merge以后,比如就是希望保留本地的 pom文件,或者就是希望保留 rls的pom文件

这个时候不需要做rebase,只需要

git checkout --ours unisound-commons-time/pom.xml

--ours 表示用 我当前所在分支的版本。

--theirs表示,用另外一个分支的版本

3、结合12的一个案例

比如做了merge虽然没有冲突,但是git diff dev一看,有个文件并不想修改,所以还想保留merge以前的本地(dev)版本

就可以 git checkout --ours **file**

这里的概念  ours和theirs表示 本地和远程 dev 和 rls

4、摘草莓

假如你想删掉一个分支,但是对于里面的一些commit想保留到另一个分支上,这个时候就可以做摘草莓的技术

5、从一个commit创建一个分支

git branch **_before_merge 679856aa5
git checkout **_before_merge

查看某次commit提交的文件

git show --name-only e893e3175

6、eclipse 换行符

CRLF换行回车是windows使用的行结束符;而LF换行是linux使用的行结束符;所以两者会发生问题。

可以修改eclipse设置使得本地使用linux的行结束符;也可以设置git的参数 core.autocrlf

I

官方文档Formatting and Whitespace

core.autocrlf

》》1、如果你在windows编程,但是其他人用非windows编程 you’ll probably run into line-ending issues at some point.

git如何解决这个问题?

git会自动将CRLF换行回车转为LF换行,当你做add a file to index的时候;与此对应,checkout的时候也会将LF换行转为CRLF换行回车需要设置:

$ git config --global core.autocrlf true

》》2、如果你是linux编程,不想git自动行结束符转换,但是如果一个文件意外的行结束符是CRLF你希望git修复他,这个时候使用 core.autocrlf为input

If you’re on a Linux or Mac system that uses LF line endings, then you don’t want Git to automatically convert them when you check out files; however, if a file with CRLF endings accidentally gets introduced, then you may want Git to fix it. You can tell Git to convert CRLF to LF on commit but not the other way around by setting core.autocrlf to input:

$ git config --global core.autocrlf input

This setup should leave you with CRLF endings in Windows checkouts, but LF endings on Mac and Linux systems and in the repository.

7、merge冲突是因为对方删除而导致

Unmerged paths:
(use "git add/rm ..." as appropriate to mark resolution) deleted by them: src/main/java/com/example/filevisitor/PrintingFileVisitor.java

Resolving this type of conflict is pretty easy. You just have to tell Git whether you want to keep the file in your current branch using command:

$ git add file_name

or if you want to remove it completely:

$ git rm file_name

8、两次git pull

这里的前提假设是你的分支要merge到dev分支

git pull  自己的分支;

Git pull dev

这样可以省好多不必要的麻烦

9、如果有一个文件你做过commit,但是你想忽略掉不做更新了怎么办?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rmmeans that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

首先进入.gitignore 文件所在的目录
$ echo debug.log >> .gitignore
如何查看gitignore项是否生效?
$ git check-ignore -v filename
$ git rm --cached debug.log
rm 'debug.log'
$ git commit -m "Start ignoring debug.log" >>>另一种情况,如果你将某个目录加入了gitignore,但是做git status可能看到添加的目录没有生效,这个时候可以
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
>>>注意在.gitignore 文件的写法(********)

./data_totrain_w2v/-----------不会真正忽略  不能以./开头
data_totrain_w2v/------------正确写法

 


10、某位牛人的说法(我还没看懂)

我多次推荐过一个 git 分支模型,它的关键思想是:长期存在的分支只有 develop 和 master,develop 是开发分支,master 是发布分支;master 分支每个节点都会以版本号打上 tag。

在实践中,会遇到一个问题。根据语义化版本的定义,大版本号升级意味着 API 的变化。当我们的 master 分支中包含超过一个大版本时,如果在一个较早的大版本上要做 bug 修复或者根据客户需求增加功能,就意味着必须新建一个长期分支。这违反了只有两个长期分支的原则。

我在这里提出一个解决方案:在做大版本更新前,fork 出一个新的 repo,未来在这个版本上的修改将在这个 repo 上执行。这样,所有 repo 都将遵守上述分支模型的约定。

git使用手册的更多相关文章

  1. git学习手册

    #git学习手册 git: Git是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理.[2] Git 是 Linus Torvalds 为了帮助管理 Linux内核开发而 ...

  2. Ubuntu下安装Git以及Git帮助手册【转】

    转自:http://milkythinking.com/blog/2011/04/17/install_git_and_manual/ Git简介 Git是一个分布式版本控制系统,对应的是SVN.CV ...

  3. svn 迁移至git操作手册

    svn 迁移至git操作手册 项目交付.版本管理工具变更等情况下,迁移svn旧历史记录有很大必要,方便后续追踪文件的提交历史,文件修改记录比对等.git自带了从svn迁移至git的工具命令,可很好的对 ...

  4. Git使用手册【转】

    转自:https://www.jianshu.com/p/e32a8e7ca93b 目录: Git是什么 基本概念 Git的诞生 Git的安装与配置 创建版本库 Git操作略览 远程仓库:git的杀招 ...

  5. Git Manual / Git使用手册 / Git, GitLab, Git Bash, TortoiseGit (建议全文复制到Word文档中通过导航窗格查看)

    Git使用手册 目录 1     引言 2     Git.GitLab简介 2.1      Git 2.2      GitLab 2.3      Git基本概念 3     运行环境 4    ...

  6. 《mac的git安装手册-1》

    <mac的git安装手册-1> 下载地址 https://git-scm.com/downloads 如果遇到上面这个问题打开系统偏好设置: OK,这样就能安装了

  7. 《mac的git安装手册-2》

    <mac的git安装手册-2> 下载地址 https://git-scm.com/downloads 如果遇到打不开的情况,请在系统偏好设置内——>安全性与隐私下 ——>选择仍 ...

  8. 常用Git命令手册

    常用Git命令手册 此文只是对Git有一定基础的人当记忆使用,比较简略,初级学员强烈推荐廖雪峰老师的Git系列教程,通俗易懂,戳此处即可开始学习 1.安装Git Linux sudo apt-get ...

  9. Git随身手册

    Git随身手册 本文是关于Git探索的一篇文章,阐述了Git的大部分命令和使用方式,并列举了几个典型的使用场景以供参考和体会. 对于Git这个分布式的VCS,从链表的角度来看待是最容易理解的: 一次c ...

  10. Git使用手册/Git教程:git fetch 将远程仓库的分支及分支最新版本代码拉取到本地

    相关文章: 关于验证是否存在ssh配置以及生成SSH Key的方法可以参照文章:Git使用手册:生成SSH Key 关于SSH Key的使用和公钥在gitHub.gitLab的配置等,请参考文章:Gi ...

随机推荐

  1. 《A Convolutional Neural Network Cascade for Face Detection》

    文章链接:   http://pan.baidu.com/s/1bQBJMQ  密码:4772 作者在这里提出了基于神经网络的Cascade方法,Cascade最早可追溯到Haar Feature提取 ...

  2. lanmp之一 (动静分离)

    一.lanmp--需求篇 1. 准备两台centos 6,其中一台机器跑mysql,另外一台机器跑apache,nginx + php 2. 同时安装apache和nginx,其中nginx启动80端 ...

  3. navicat 破解

    首先上官网上下载LINUX版本: http://www.navicat.com/download 下载 navicat110_mysql_en.tar.gz 文件 下载后解压tar文件 tar -zx ...

  4. SQL多表查询,消除表中的重复的内容

    看到朋友再写一个SQL语句:两个表a1表中有SN.SN2.TN,b1表有SM.SM2.TN2,若a1的SN中的数据和b1的SM中的数据是一致的,那么将a1中对应的数据修改成b1中对应的数据. upda ...

  5. SerialPort 串口开发

    private SerialPort sPort = new SerialPort(); //串行端口资源 /// <summary> /// 函数功能:打开串口/关闭串口 /// < ...

  6. splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目

    删除位于 index 2 的元素,并添加一个新元素来替代被删除的元素: <script type="text/javascript"> var arr = new Ar ...

  7. IIS配置域用户自动登录

    1.首先确定IIS所在计算机是否已添加到域中:右击计算机->属性,在计算机名称,域,工作组设置中可看到计算机所在的域,若没有,可点击更改设置,再点击更改,选择要绑定的域即可(需要用域账户登录). ...

  8. 2016最后一贴,终于调通一个测试示例,并发现一个BUG???

    真的难点在于第一次调通.纠结五天,终于搞出界面. 也发现了一个书上代码,编辑用户时死活不通的情况,我将Links去了,改在data里,我X,,全OK了.. 原来的代码: onAdd: function ...

  9. Linux下Keepalived+LVS-DR模式配置高可用负载均衡集群

    一.环境说明:     操作系统:Centos-6.5_x86_64    keepalived软件安装在node2和node3机器上.     实际安装之前,先关闭keepalived节点(node ...

  10. 【leetcode】ZigZag Conversion

    题目简述 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows ...