zoukankan      html  css  js  c++  java
  • git mv与直接mv的区别

    git mv

    行为:

      1.创建一个和之前文件内容一样的文件,文件名为新的文件名

      2.将原来的文件删除

      3.将删除的文件添加到暂存区

      4.将新建的文件添加到暂存区

    $ git mv a a1

    $ git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)

      renamed: a -> a1

    提交:

      直接 git commit -m ''

    $ git commit -m 'rename a to a1'

    [master 863356d] rename a to a1
      1 file changed, 0 insertions(+), 0 deletions(-)
      rename a => a1 (100%)

    $ git status
      On branch master
      nothing to commit, working directory clean

    恢复:

      1. 恢复暂存区(git reset HEAD oldName)

      2. 将新添加的文件从暂存区移除(git reset HEAD newName)

      3. 将原来的文件从暂存区恢复到工作区(git checout -- oldName)

      3. 从工作区删除新添加的这个文件(rm newName)

    $ git reset HEAD a
    Unstaged changes after reset:
    D       a
    
    $ git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
            new file:   a1
    
    Changes not staged for commit:
      (use "git add/rm <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            deleted:    a
    
    
    $ git reset HEAD a1
    Unstaged changes after reset:
    D       a
    
    $ git status
    On branch master
    Changes not staged for commit:
      (use "git add/rm <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            deleted:    a
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
            a1
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
    $ git checkout -- a
    
    $ git status
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
            a1
    
    nothing added to commit but untracked files present (use "git add" to track)
    
    $ rm a1
    
    $ git status
    On branch master
    nothing to commit, working directory clean

    直接调用系统的mv

    行为:

      只是重命名了一个文件

    $ mv a a1
    
    $ git status
    On branch master
    Changes not staged for commit:
      (use "git add/rm <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            deleted:    a
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
            a1
    
    no changes added to commit (use "git add" and/or "git commit -a")

    提交:

      1.把新文件和旧文件加入暂存区

      2.提交暂存区的改动

    $ git add a a1
    
    $ git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
            renamed:    a -> a1
    
    
    $ git commit -m 'rename a to a1'
    [master 8b02e6a] rename a to a1
     1 file changed, 0 insertions(+), 0 deletions(-)
     rename a => a1 (100%)
    
    $ git status
    On branch master
    nothing to commit, working directory clean

    恢复:

      1.将旧文件恢复到工作区,git checout -- oldName

      2.将新文件删除, rm newName

    $ git checkout -- a
    $ rm a1
    
    $ git status
    On branch master
    nothing to commit, working directory clean
  • 相关阅读:
    url 转码 urlencode和 urldecode
    通过启动函数定位main()函数
    关于溢出的总结1
    http://ctf.bugku.com/challenges#Mountain%20climbing:bugku--Mountain-Climbing
    http://ctf.bugku.com/challenges#love:bugku--love
    http://ctf.bugku.com/challenges#%E9%80%86%E5%90%91%E5%85%A5%E9%97%A8:bugku--逆向入门
    http://ctf.bugku.com/challenges#Timer(%E9%98%BF%E9%87%8CCTF):Bugku——Timer(阿里CTF)
    http://ctf.bugku.com/challenges#%E6%B8%B8%E6%88%8F%E8%BF%87%E5%85%B3--游戏过关
    填坑专记-手脱FSG壳

  • 原文地址:https://www.cnblogs.com/413xiaol/p/10555165.html
Copyright © 2011-2022 走看看