1. checkout one branch, show status

user@vbox:/mnt/tmp$ git checkout master
Switched to branch 'master'
user@vbox:/mnt/tmp$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   testfile.c
#
no changes added to commit (use "git add" and/or "git commit -a")

2. show diff, turns out no diff
user@vbox:/mnt/tmp$ git diff

user@vbox:/mnt/tmp$

3. checkout modified file, show status, testfile.c doesn't change.

user@vbox:/mnt/tmp$ git checkout -- testfile.c

user@vbox:/mnt/tmp$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   testfile.c
#
no changes added to commit (use "git add" and/or "git commit -a")

4. solution. Don't know why, but this works for me.
user@vbox:/mnt/tmp$ git add testfile.c
user@vbox:/mnt/tmp$ git status
# On branch master
nothing to commit, working directory clean
user@vbox:/mnt/tmp$

git checkout not discard changes的更多相关文章

  1. git命令--git checkout 之 撤销提交到暂存区的更改

    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master) $ git status [由于工作区文件被修改了,所以显示为红色] On branc ...

  2. [Git]checkout 指定版本

    Task:知道commit号,如何checkout 指定版本 1. 切换到master: git checkout master 2. 下载最新代码:  git pull 3. 下载head: git ...

  3. git分布式版本控制系统权威指南学习笔记(六):git reset、get stash、git checkout总结

    文章目录 1. 概述 2. 如何把修改暂存起来,留着以后使用? 2.1 使用场景 2.2 git stash 暂存进度 2.3 查看进度 2.4 恢复进度 3. 如何撤销工作区的修改? 4. 如何把暂 ...

  4. 代码回滚:git reset、git checkout和git revert区别和联系

    git reset.git checkout和git revert是你的Git工具箱中最有用的一些命令.它们都用来撤销代码仓库中的某些更改,而前两个命令不仅可以作用于提交,还可以作用于特定文件. 因为 ...

  5. 分支合并git checkout adview git merge adview3

    分支合并 git checkout adview git merge adview3

  6. 每天一命令 git checkout

    检出 checkout  是git常用命令之一.主要用于创建切换分支,覆盖本地修改等 git checkout 用于显示工作区,暂存区,版本库中文件的区别 git checkout -b branch ...

  7. git checkout -b 的详细讲解

    创建分支: $ git branch mybranch 切换分支: $ git checkout mybranch 创建并切换分支: $ git checkout -b mybranch 更新mast ...

  8. [译]git checkout

    git checkout git checkout提供3种不同的功能: checking out文件, checking out commits, checking out branch. check ...

  9. git checkout 命令详解

    转自:http://www.cnblogs.com/hutaoer/archive/2013/05/07/git_checkout.html?utm_source=tuicool&utm_me ...

随机推荐

  1. discuz之同步登入

    前言   首先感谢dozer学长吧UCenter翻译成C# 博客地址----------->http://www.dozer.cc/   其次感谢群友快乐々止境同学的热心指导,虽然萍水相逢但让我 ...

  2. Facebook

    Facebook登录为iOS Facebook的SDK为iOS提供了各种登录的经验,你的应用程序可以使用它来 ​​验证一个人.这份文件包括了所有你需要知道,以落实Facebook登录在你的iOS应用程 ...

  3. apple开发者账号申请

    1.  登陆appleID. 2. 进入 Your Account 3. 在Account Summary 中的MemberShips中选择第一个(界面大概如下) 4.选择后进入下图. 5. yes ...

  4. ASP.NET MVC与RAILS3的比较

    进入后Web年代之后,MVC框架进入了快速演化的时代,Struts等垂垂老矣的老一代MVC框架因为开发效率低下而逐渐被抛弃,新一代的MVC则高举敏捷的大旗,逐渐占领市场,其中的代表有Rails (ru ...

  5. C#&java重学笔记(面向对象)

    C#部分 1.C#有一个internal关键字,指字段可以同一个程序集中访问,出了程序集不行.还有一个protected internal(没有先后之分)修饰词,指只能在同一个程序集中的子类访问 2. ...

  6. 有趣 GIF 动图集 - 仿佛每张小动图都诉说了一个小笑话或者小故事

    点这里 来自法国南特(Nantes)的 Guillaume Kurkdjian 目前还是个学生.Kurkdjian 擅长创作一些平面动态图像,这些有趣的小动图仿佛每张都诉说了一个小笑话或者小故事,像个 ...

  7. POJ 2039

    #include<iostream> #include<stdio.h> #include<string> #define MAXN 20 using namesp ...

  8. Spring mvc json null

    http://blog.csdn.net/zdsdiablo/article/details/9429263

  9. C# WINFORM 捕获全局异常

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Thr ...

  10. 错误处理--pure specifier can only be specified for functions

    错误处理--pure specifier can only be specified for functions 今天下载了log4cpp的源代码,在VC6下编译时出现错误: ..\..\includ ...