02_创建Git仓库,克隆仓库,git add,git commit,git push,git pull,同行冲突,不同行冲突的结局方案,git mergetool的使用

简介: 1 创建Git资源库,残酷目录信息 创建git资源库的命令: git init –bare 仓库名称 (其中-bare表示的意思是空的库的意思) 进入E:\software\repository\git\itheima28,截图如下: hooks:提交一些脚本文件 info:存放一些个人信息,配置信息 objects:所有数据存放位置 re

1 创建Git资源库,残酷目录信息

创建git资源库的命令:

git init –bare 仓库名称 (其中-bare表示的意思是空的库的意思)

进入E:\software\repository\git\itheima28,截图如下:

hooks:提交一些脚本文件

info:存放一些个人信息,配置信息

objects:所有数据存放位置

refs:git指针信息,记录了修改了什么等的信息

config:核心的配置信息

description:描述信息

HEAD:存放的分支信息。

2 使用上面创建的库,进入E:\git\developer\user1

3 在用户文件夹下把资源clone下来

         gitclone <仓库目录> /g/software/repository/git/itheima <用户目录> .

         注意:clone时候用户目录必须为空

进入user1目录下

 

 

其中E:\software\developer\user1\.git\objects位本地库存放数据的文件夹

4 E:\software\developer\user1\中创建一个文件并将文件上传到仓库中

查看E:\software\developer\user1下仓库文件的状态

使用git add将文件纳入到版本控制中,并使用git commit进行提交。

5 要将文件推送到远程仓库

上面的commit过程知识将内容提交到本地库,要想将文件推送到远程仓库,需要执行git push命令。

推送到远程共享版本仓库中取

git push origin master

查看有没有提交,方式:

1 user1的同级目录下创建user2

2 使用克隆命令,获得远程仓库中的内容。

6 user2下修改readme文件,最终提交修改的过程演示:

在提交过程中会出现vim编辑器,弹出它编辑日志信息。

将提交的文件推送到远程服务器

7  user2从远程服务器上拉文件,使用命令是git pull

再次修改user1下的文件,并提交

这里要使用git add readme.txt文件

 

关于演示冲突合并的过程,可以查看另外一篇本人的博客:

http://blog.csdn.net/tototuzuoquan/article/details/41398025

  1. 演示冲突合并

(1)、演示不同行冲突

a、进入user2,修改readme.txt文件

b  在未进行git pull的情况下,进入user1,修改readme.txt文件

总结:如果修改的是同一个文件中的不同行,这时候git push的时候出现了问题。上面提在提交之前先git pull

这时候要进入这个文件进行修改,然后再提交修改:

(2)、不同行的合并问题

下面是修改E:\software\developer\user1中的readme.txt文件

将修改的文件内容推送到远程服务器



 

删掉readme.txt.orig

 

总结:

git pull 之后有冲突:

 

$ git pull

remote: Counting objects: 5, done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 3 (delta 0), reused 0 (delta 0)

Unpacking objects: 100% (3/3), done.

From g:/software/repository/git/itheima26

   50db030..a04027a  master     -> origin/master

Auto-merging readme.txt

CONFLICT (content): Merge conflict in readme.txt

Automatic merge failed; fix conflicts and then commit the result.

 

 

解决方法:

1.git mergetool

         调用上面命令之后会提示你输入编辑方法,输入:beyond compare 进入编辑器.

 

2.编辑完之后.调用git commit -a 把当前目录中所有都提交到本地库中.

 

3.git push origin master 提交到远程库中.

 

目录
相关文章
|
18天前
|
开发工具 git
git篇3:idea中创建项目并提交到远程Git仓库
git篇3:idea中创建项目并提交到远程Git仓库
|
29天前
|
开发工具 git
记IDEA Git版本回退并push到远程操作
记IDEA Git版本回退并push到远程操作
29 1
记IDEA Git版本回退并push到远程操作
|
1月前
|
开发工具 git 开发者
|
1月前
|
开发工具 git 开发者
Git Pull vs. Git Fetch:深度解析
【2月更文挑战第29天】
135 0
Git Pull vs. Git Fetch:深度解析
|
1月前
|
开发工具 git
|
1月前
|
开发工具 git
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
|
2月前
|
网络安全 开发工具 git
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
20 0
|
7天前
|
开发工具 git
完美解决git 执行git push origin master指令 报错command not found
完美解决git 执行git push origin master指令 报错command not found
13 0
|
29天前
|
开发工具 C语言 数据安全/隐私保护
git提交代码到远端仓库的方法详解
git提交代码到远端仓库的方法详解
|
1月前
|
算法 开发工具 git
【git 实用指南】git 增加 本地代码 git add 相关命令和复杂情况需求
【git 实用指南】git 增加 本地代码 git add 相关命令和复杂情况需求
93 0