zoukankan      html  css  js  c++  java
  • git checkout not discard changes

    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$

  • 相关阅读:
    JavaScript(ASP)常用代码
    用JavaScript + jMail发邮件
    SQL语句导入导出大全
    C#编程方式执行包的任务
    匹配版本号
    c# web 页面帮定数据的 7中方式
    好书
    奇怪的异步调用,那位高手能帮忙看一下?
    vb6 调用c# 服务
    易犯的错误忘了初始化对象
  • 原文地址:https://www.cnblogs.com/hfyinsdu/p/3725591.html
Copyright © 2011-2022 走看看