0
点赞
收藏
分享

微信扫一扫

git 修改-撤销


git status
初始状态是,什么都没有修改:

# On branch master
nothing to commit (working directory

修改了一个文件fu ,状态变成

[root@172.18.4.100 gitlearn]# git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: fu
#
no changes added to commit (use "git add" and/or "git commit -a")

如果想把这个修改 加入暂存区 ,准备提交 使用 git add

git add fu
执行之后的状态:

[root@172.18.4.100 gitlearn]# git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: fu
#

这时候,状态就变成 fu处于 暂存区了, 准备去提交。
但如果这时候,想从暂存区撤销回来 , 根据提示,用 git reset

git reset HEAD fu

# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: fu
#
no changes added to commit (use "git add" and/or "git commit -a")

现在又变成 修改,但还没有放入暂存区, 如果这时候,想近一步回退, 回退到什么都没修改的状态,根据提示
使用 git checkout 命令

git checkout – fu

上面这条命令,显示的问题,会把两个连字符 连在一起, 其实是两个连字符。
回到了一开始

# On branch master
nothing to commit (working directory


举报

相关推荐

0 条评论