1新建一个存储git的文件夹,命令是:
toto@toto-K45VD:~$ mkdir gitfolder

2初始化一个git仓库,命令是:
toto@toto-K45VD:~$cd gitfolder/
toto@toto-K45VD:~/gitfolder$ls
toto@toto-K45VD:~/gitfolder$git init
初始化空的 Git版本库于 /home/toto/gitfolder/.git/
		
注意:如果是第一次使用git,还要对git对进行如下配置
git config --global user.email "yourEmail@qq.com"
git config --global user.name "tuzuoquan"

3 显示仓库内的所有内容,命令是:
toto@toto-K45VD:~/gitfolder$ll
总用量 12
drwxrwxr-x 3 toto toto 4096 11月 22 23:12 ./
drwxr-xr-x 31 toto toto 4096 11月 22 23:09 ../
drwxrwxr-x 7 toto toto 4096 11月 22 23:12 .git/

4 查看git仓库状态
toto@toto-K45VD:~/gitfolder$ git status
位于分支 master
初始提交
无文件要提交(创建/拷贝文件并使用"git add" 建立跟踪)
toto@toto-K45VD:~/gitfolder$

5 在仓库里面创建一个文件,并将这个文件添加到仓库中(注意也可以使用git add .将之添加到版本仓库中)
toto@toto-K45VD:~/gitfolder$ touch readme.txt
toto@toto-K45VD:~/gitfolder$ git status
位于分支 master
初始提交

未跟踪的文件:
  (使用 "git add <file>..." 以包含要提交的内容)
    readme.txt
提交为空,但是存在尚未跟踪的文件(使用
	"git	add" 建立跟踪)
toto@toto-K45VD:~/gitfolder$ls
readme.txt

6 将新建的文件添加到跟踪,命令如下:
toto@toto-K45VD:~/gitfolder$ git status
位于分支 master
初始提交
要提交的变更:
  (使用 "git rm --cached <file>..." 撤出暂存区)
	新文件:readme.txt

toto@toto-K45VD:~/gitfolder$

7讲readme.txt提交到git版本仓库,命令如下:
toto@toto-K45VD:~/gitfolder$git commit -m 'commit readme.txt'
[master(根提交) ad32b61]
commit readme.txt
 1  file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.txt
toto@toto-K45VD:~/gitfolder$git status
位于分支 master
无文件要提交,干净的工作区
toto@toto-K45VD:~/gitfolder$

8查看当前分支信息,命令如下:
toto@toto-K45VD:~/gitfolder$git branch
*master
	
或者使用
git branch -a

9查看日志信息,命令如下:
toto@toto-K45VD:~/gitfolder$]git log
commit ad32b612b632ab62e6fe46630f3c6b03a1ff1ce3
Author: tuzuoquan <you@example.com>
Date:Sat Nov 22 23:31:12 2014 +0800

    commit readme.txt
toto@toto-K45VD:~/gitfolder$]git status
位于分支 master
无文件要提交,干净的工作区
toto@toto-K45VD:~/gitfolder$

10编辑readme.txt中的内容,并将之添加跟踪,并将之提交到版本仓库中去
readme.txt中的内容如下:
23:39 master readme.txt
			
查看git版本的状态,将readme.txt添加到git上.整个过程的命令如下:
toto@toto-K45VD:~/gitfolder$git status
位于分支 master
尚未暂存以备提交的变更:
  (使用 "git add <file>..." 更新要提交的内容)
  (使用 "git checkout -- <file>..." 丢弃工作区的改动)

	修改:readme.txt

修改尚未加入提交(使用 "git add" 和/或"git commit -a")
toto@toto-K45VD:~/gitfolder$git add readme.txt
toto@toto-K45VD:~/gitfolder$git status
位于分支 master
要提交的变更:
  (使用 "git reset HEAD <file>..." 撤出暂存区)

	修改:readme.txt

toto@toto-K45VD:~/gitfolder$git add readme.txt
toto@toto-K45VD:~/gitfolder$git commit -m 'commited after modify'
[master b5c97f9] commited after modify
 1 file changed, 2 insertions(+)

11创建一个develop分支,查看所有的分支,命令如下:
toto@toto-K45VD:~/gitfolder$git branch develop
toto@toto-K45VD:~/gitfolder$git branch -a
  develop
*master
toto@toto-K45VD:~/gitfolder$

12查看git的日志信息
toto@toto-K45VD:~/gitfolder$git log
commit b5c97f9ad74458b1ec6a7fc38684305e45fff4de
Author:tuzuoquan <you@example.com>
Date:Sat Nov 22 23:49:49 2014 +0800

    commited after modify

commit ad32b612b632ab62e6fe46630f3c6b03a1ff1ce3
Author: tuzuoquan <you@example.com>
Date: Sat Nov 22 23:31:12 2014 +0800

    commit readme.txt
toto@toto-K45VD:~/gitfolder$

13切换到develop的分支,命令如下:
toto@toto-K45VD:~/gitfolder$git checkout develop
切换到分支 'develop'
toto@toto-K45VD:~/gitfolder$ls
readme.txt
toto@toto-K45VD:~/gitfolder$git branch
*develop
  master
toto@toto-K45VD:~/gitfolder$	

14创建2.txt,并将文件添加到对应的分支的版本仓库中.
toto@toto-K45VD:~/gitfolder$touch 2.txt
toto@toto-K45VD:~/gitfolder$ls
2.txt readme.txt
toto@toto-K45VD:~/gitfolder$git status
位于分支 develop
未跟踪的文件:
  (使用 "git add <file>..." 以包含要提交的内容)

	2.txt

提交为空,但是存在尚未跟踪的文件(使用"git add" 建立跟踪)
toto@toto-K45VD:~/gitfolder$vi 2.txt


14 切换到develop分支
toto@toto-K45VD:~/gitfolder$ git checkout develop 已经位于 'develop' 查看切换后的分支 toto@toto-K45VD:~/gitfolder$ git branch -a * develop master toto@toto-K45VD:~/gitfolder$ ls 2.txt  readme.txt
15 转换到master分支然后创建一个
toto@toto-K45VD:~/gitfolder$ git checkout master 切换到分支 'master' 创建一个分支develop2 toto@toto-K45VD:~/gitfolder$ git branch develop2 toto@toto-K45VD:~/gitfolder$ git checkout develop2 切换到分支 'develop2' toto@toto-K45VD:~/gitfolder$ ls 2.txt  readme.txt
16 切换分支信息,并查看所在分支信息
toto@toto-K45VD:~/gitfolder$ git checkout develop 切换到分支 'develop' toto@toto-K45VD:~/gitfolder$ git branch * develop develop2 master toto@toto-K45VD:~/gitfolder$ toto@toto-K45VD:~/gitfolder$ git branch * develop develop2 master toto@toto-K45VD:~/gitfolder$ ls 2.txt  readme.txt 对develop分支中的readme.txt文件中的内容进行修改 toto@toto-K45VD:~/gitfolder$ vi readme.txt toto@toto-K45VD:~/gitfolder$ git status 位于分支 develop 尚未暂存以备提交的变更: (使用 "git add <file>..." 更新要提交的内容) (使用 "git checkout -- <file>..." 丢弃工作区的改动) 修改:         readme.txt 未跟踪的文件: (使用 "git add <file>..." 以包含要提交的内容) .2.txt.swp 2.txt 修改尚未加入提交(使用 "git add" 和/或 "git commit -a") toto@toto-K45VD:~/gitfolder$ //将修改添加到分支 toto@toto-K45VD:~/gitfolder$ git add . toto@toto-K45VD:~/gitfolder$ git commit -m 'xiugai' [develop 722fbeb] xiugai 3 files changed, 2 insertions(+) create mode 100644 .2.txt.swp create mode 100644 2.txt
17 切换分支到branch上,同时也修改develop分支中的文件readme.txt文件
toto@toto-K45VD:~/gitfolder$ git branch * develop develop2 master toto@toto-K45VD:~/gitfolder$ git checkout develop2 切换到分支 'develop2' toto@toto-K45VD:~/gitfolder$ ls readme.txt toto@toto-K45VD:~/gitfolder$ vi readme.txt toto@toto-K45VD:~/gitfolder$ git status 位于分支 develop2 尚未暂存以备提交的变更: (使用 "git add <file>..." 更新要提交的内容) (使用 "git checkout -- <file>..." 丢弃工作区的改动) 修改:         readme.txt 修改尚未加入提交(使用 "git add" 和/或 "git commit -a") toto@toto-K45VD:~/gitfolder$ git commit -m 'develop2 commited after modified' 位于分支 develop2 尚未暂存以备提交的变更: 修改:         readme.txt 修改尚未加入提交 toto@toto-K45VD:~/gitfolder$ git add . toto@toto-K45VD:~/gitfolder$ git commit -m 'develop2 commited after modified' [develop2 8e8dc62] develop2 commited after modified 1 file changed, 1 insertion(+) toto@toto-K45VD:~/gitfolder$
18 先将develop合并到master,并解决合并冲突问题
toto@toto-K45VD:~/gitfolder$ git merge develop 自动合并 readme.txt 冲突(内容):合并冲突于 readme.txt 自动合并失败,修正冲突然后提交修正的结果。 toto@toto-K45VD:~/gitfolder$ 冲突的内容如下: 23:39 master readme.txt <<<<<<< HEAD 11 : 00 ======= 08:47 修改 >>>>>>> develop 为了解决合并时出现的冲突,需要修改readme.txt中的内容,修改后的内容如下: 23:39 master readme.txt 08:47 修改
19 查看状态,并将修改正确后的文件提交到仓库中
toto@toto-K45VD:~/gitfolder$ git status 位于分支 develop2 您有尚未合并的路径。 (解决冲突并运行 "git commit") 要提交的变更: 新文件:       .2.txt.swp 新文件:       2.txt 未合并的路径: (使用 "git add <file>..." 标记解决方案) 双方修改:     readme.txt
20 将修改后的所有内容添加到仓库中
toto@toto-K45VD:~/gitfolder$ git add . toto@toto-K45VD:~/gitfolder$ git status 位于分支 develop2 所有冲突已解决但您仍处于合并中。 (使用 "git commit" 结束合并) 要提交的变更 新文件:       .2.txt.swp 新文件:       2.txt 修改:         readme.txt toto@toto-K45VD:~/gitfolder$ git commit -m 'commit all' [develop2 749fb3c] commit all toto@toto-K45VD:~/gitfolder$ 查看修改后的内容 toto@toto-K45VD:~/gitfolder$ cat readme.txt 23:39 master readme.txt 08:47 修改 toto@toto-K45VD:~/gitfolder$

												

1git命令的使用,查看git仓库状态,添加文件到git跟踪,git提交,查看git分支,查看git仓库日志信息,切换git分支,解决git分支合并后出现冲突的问题的更多相关文章

  1. git无法添加文件夹

    如标题所示,在webapp下面创建了个空的pages文件夹,想着先提交一下,无奈怎么都提交不了,后来试着在文件夹下面随便添加了个文件就可以提交了, 也不知道是什么原因.

  2. Git 无法添加文件夹下的文件

    尚未暂存以备提交的变更: (使用 "git add <文件>..." 更新要提交的内容) (使用 "git checkout -- <文件>... ...

  3. git 无法添加文件夹下文件

    最近做项目时,发现无法提交某个子文件夹下的文件. google后发现可能是该子文件夹下有.git文件夹导致无法上传. 删除子文件夹下.git后,依然无法提交子文件夹下的文件. 继续google, 尝试 ...

  4. 向 Git 服务器添加 SSH 公钥

    . . . . . 在网上很少找到文章有提到如何将自己的 Git 远程仓库配置成可以通过 SSH 公钥方式认证的,而几乎清一色都是告诉你怎么通过 web 界面向 GitHub 添加 SSH 公钥.LZ ...

  5. 向git服务器添加shh公钥

    步骤一,从客户端获得 SSH 公钥 为了使客户端可以向 Git 服务器提供 SSH 公钥,首先要确认客户端拥有公钥.SSH 的密钥存储在 ~/.ssh/ 目录下,下面我们查看一下这里面都有哪些文件: ...

  6. Git学习笔记(一)创建版本库并添加文件

    最近从廖雪峰老师的个人网站上学习git,做点笔记. ★★★★★ 先注册自己的username和email,否则会报如下错误: 注册:git config --global user.name &quo ...

  7. git 学习记录—— git 中的仓库、文件状态、修改和提交操作等

    最近开始学习使用版本控制工具  git .学习方式主要通过阅读 git 网站上的 Pro git 和动手实践,使用的系统为 Ubuntu16.04LTS,以及 Windows 8.1. 本文主要关注 ...

  8. 使用git将本地文件提交到github存储库

    1.首先你要安装git https://git-for-windows.github.io/ 去官网自行下载对应版本 2.安装好git服务器后,找到你项目的文件夹,右键git bash here打开命 ...

  9. git :.gitigrone文件不生效的解决办法

    真正的原因是.gitignore只能忽略那些尚未被track的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的.一个简单的解决方法就是先把本地缓存删除(改变成未track状 ...

随机推荐

  1. 《C++ Primer》学习笔记:向vector对象添加元素蕴含的编程假定

    练习<C++ Primer>中的3.14节时,当敲入: #include <iostream> #include <string> using namespace ...

  2. [PA 2014]Iloczyn

    Description 斐波那契数列的定义为:k=0或1时,F[k]=k:k>1时,F[k]=F[k-1]+F[k-2].数列的开头几项为0,1,1,2,3,5,8,13,21,34,55,…你 ...

  3. codeforces 842C Ilya And The Tree

    Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very ...

  4. [ZJOI2007]报表统计

    题目描述 Q的妈妈是一个出纳,经常需要做一些统计报表的工作.今天是妈妈的生日,小Q希望可以帮妈妈分担一些工作,作为她的生日礼物之一. 经过仔细观察,小Q发现统计一张报表实际上是维护一个非负整数数列,并 ...

  5. Evensgn 的债务

    问题 A: Evensgn 的债务 大致题意:a欠b5元,b欠c5元,那么最小债务总额为a欠c5元,给你关系,求最小债务总额! 不想说话...一句超级大水题,我居然没读懂!!差点想到网络流了...其实 ...

  6. 【20170920校内模拟赛】小Z爱学习

    所有题目开启-O2优化,开大栈空间,评测机效率为4亿左右. T1 小 Z 学数学(math) Description ​ 要说小 Z 最不擅长的学科,那一定就是数学了.这不,他最近正在学习加法运算.老 ...

  7. 【LSGDOJ 1408】邮局

    题目描述 一些村庄被建在一条笔直的高边公路边上.我们用一条坐标轴来描述这条高边公路,每一个村庄的坐标都是整数.没有两个村庄坐标相同.两个村庄问的距离,定义为它们坐标值差的绝对值. 我们需要在一些村庄建 ...

  8. SpringBoot多环境部署,在启动时动态设置相应的配置文件

    项目中,往往在测试环境和正式环境拥有不同的配置,例如数据库连接,第三方库的appkey等.这时候,我们就要在不同的环境启用不同的配置 下面新建三个文件,分别表示开发环境,生产环境和测试环境的配置文件 ...

  9. python dataframe数据条件筛选

    一般情况下我们从一堆数据中选择我们获取想要的数据会通过一下方式: (1)创建链表或数组: (2)用for 循环遍历所有数据,将想要的存入链表或数组. 但是python中我们不需要这么做,我们可以用Pa ...

  10. IOS和OSX事件传递机制

    本文ios部分转载自: http://zhoon.github.io/ios/2015/04/12/ios-event.html iOS的事件有好几种:Touch Events(触摸事件).Motio ...