[Practical Git] Compare file changes with git diff

It can be helpful to see the changes between two sets of code; git diff lets us do this by comparing two Git references and outputting the differences between them. In this lesson, we show how to use git diff along with the --stat--cachedHEADorigin/masterfile(s)/dir(s) options.

If you want to see the difference between stagin area with last commit:

git diff --cached

See the all umcommit changes:

git diff HEAD

See the different with branch:

git diff origin/master   //will show all the change which in local but not in remote master

Compare the file with remote branch:

git diff origin/master getRandomNumber.js  // show the difference between local getRandomNumber.js file with remote master branch
时间: 2024-08-10 14:59:02

[Practical Git] Compare file changes with git diff的相关文章

Git建立本地服务器和git命令的使用

建立本地Git 服务器 [[email protected] ~]# useradd git ------------------创建一个git用户[[email protected] ~]# mkdir /git‐root/[[email protected] ~]# cd /git‐root/[[email protected] git‐root]# git init ‐‐bare shell.git --------------初始化仓库[[email protected] git‐roo

Git在Windows环境下配置Diff以及Merge工具---DiffMerge

参考出处:http://coding4streetcred.com/blog/post/Configure-DiffMerge-for-Your-Git-DiffTool主要转自:http://blog.csdn.net/u010232305/article/details/51767887 1.下载DiffMerge http://sourcegear.com/diffmerge/downloads.php,楼主选择的是 Windows Installer (64bit),安装直接下一步,这一

git 查看对比的方法log diff

1.有冲突时可以用 git status查看 2.通过git log查看commit   参考:https://www.jianshu.com/p/f2fa0a590370 (1)通过author  commiter等搜索 git log --author="John"   它接受正则表达式,返回所有作者名字满足这个规则的提交 :用正则  git log --author="John\|Mary" 注意作者的邮箱地址也算作是作者的名字,所以你也可以用这个选项来按邮箱

如何理解git checkout -- file和git reset HEAD -- file

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001374831943254ee90db11b13d4ba9a73b9047f4fb968d000 首先需要知道工作区(working diretory)和暂存区(Stage)这两个概念.工作区的该概念不仅包含你实际操作.更改的文件还应当包括当前修改但未add存入暂存区的文件变化信息,暂存区的作用则是临时存储文件的变化信息,在gi

Git 基础再学习之:git checkout -- file

首先明白一下基本概念和用法,这段话是从前在看廖雪峰的git教程的时候摘到OneNote的 准备工作: 新建了一个learngit文件夹,在bash中cd进入文件夹,用以下命令创建一个仓库. $ git init 添加一个文本文件one.txt,里面写个内容 "one".准备工作完成.文件夹情况如下: 实验开始: 实验一:没有add,没有commit 此时不对文件做任何提交,用git status 查看一下文件状态: 说明是完全没有 git add 的 进入文件夹,把文本文件 one.t

Git - 使用命令和P4Merge进行diff

P4Merge P4Merge是Git的一个第三发Diff和Merge工具(可视化冲突解决工具). 下载地址: https://www.perforce.com/downloads/visual-merge-tool 安装的时候只需要勾选p4merge即可: 然后需要把p4merge的路径添加到环境变量PATH里面. 这样操作后, 就可以通过命令行启动p4merge了: 配置p4merge作为Git的diff tool: git config --global diff.tool p4merge

[Practical Git] Format commit history with git log arguments

When running the git log command, we can pass in options as arguments toformat the data shown for each commit. In this lesson, we show how to use the oneline, decorate, graph, stat, and p options with git log. Show it oneline: git log --oneline git l

【转】Git详解之一:Git起步

原文网址:http://blog.jobbole.com/25775/ 原文:<Pro Git> 起步 本章介绍开始使用 Git 前的相关知识.我们会先了解一些版本控制工具的历史背景,然后试着让 Git 在你的系统上跑起来,直到最后配置好,可以正常开始开发工作.读完本章,你就会明白为什么 Git 会如此流行,为什么你应该立即开始使用它.(查看Git详解系列的全部文章) 1.1 关于版本控制 什么是版本控制?我真的需要吗?版本控制是一种记录若干文件内容变化,以便将来查阅特定版本修订情况的系统.在

GIT笔记(1) GIT的入门(创建,修改,撤销,删除)

一)GIT的创建 1.首先建立工作区 Mkdir learngit Cd learngit Pwd 2.通过git 的初始化建立使其变成仓库 a) git init() Initialized empty Git repository in /Users/michael/learngit/.git/ 一般情况下会出现.git的目录.用来跟踪管理版本库(一般是隐藏的要用lis -ah看到) 二)GIT的划分 1   GIT划分为版本库与工作区. 1)工作区 一般就是平时看到的目录,如learngi