场景: 对于某个Git控制下的文件进行了修改,但是改的不满意,想退回到改之前的版本。

 

解决方法:

1 ,获取要回退到的提交的hash代码

2 ,checkout对应的以本,格式为: git checkout <hash> <filename>

 

举例:

 

回退所有文件: git checkout d98a0f565804ba639ba46d6e4295d4f787ff2949

回退某个文件:   git checkout  d98a0f565804ba639ba46d6e4295d4f787ff2949 src/main/main.c

 

git checkout master

git branch -D test_feature # see note about -D below

git checkout test_feature # should track origin/test_feature

 

 

git 放弃本地修改,远程分支强制覆盖本地

 

git fetch --all    //只是下载代码到本地,不进行合并操作

git reset --hard origin/分支名如master    //把HEAD指向最新下载的版本

相关文章:

  • 2022-12-23
  • 2021-09-15
  • 2021-08-07
  • 2021-05-15
  • 2022-01-13
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
相关资源
相似解决方案