(1)git log 查找目标版本的commitID,复制下来 (2)git checkout 目标版本commitID,此时就进入了旧版本的代码,观察可知是切换了一个旧版本代码的临时分支 (3)git checkout 原来的分支,这就回到了最新的代码
1、git checkout:检查出特定版本的文件 git checkout 命令用于切换分支或恢复工作目录中的文件到指定的提交。 恢复工作目录中的文件到某个提交: git checkout<commit>--<filename> 例如,将 file.txt 恢复到 abc123 提交时的版本: git checkout abc123--file.txt 切换到特定提交: git checkout<commit> 例如:...
2.git checkout 切换分支 如果我们目前在master分支,情况如下图: 我们现在需要切换到newImage分支,所以可以 git checkout newImage git commit 我们就会发现newImage已经到下方了,而且*这个符号正在newImage上面,也就是说目前我们在的分支是newImage。 3.git checkout -b 一次性搞定创建与切换分支 如果你觉得以上创...
我们可以通过checkout命名轻松的移动HEAD到不同的<commitID>上,在上一处对commit的理解还是一个动词性的(提交)。这里commit却好像是变成了一个名词——快照(个人跟乐意用<commitID>来表示)。 怀疑阶段——我究竟在 提交(git commit <file_path>)什么? git commit <file_path>操作,开始会认为是提交了你在Workin...
使用checkout进行检出,选择自己的branch(分支)或者检出master分支后new branch(创建新分支)并切换到自己的分支 然后编写代码,当日工作完成后进行commit(预提交),同时需要注释本次提交的简介(mark)。 如果本分支有两人以上同时开发,在push(提交到远程git仓)之前需要先pull更新 ...
git checkout--<file> 切换到特定提交: 你可以使用提交的哈希值<commit-hash>来切换到特定的提交状态。这将使你进入"分离头指针"状态,只能查看历史记录,而不能进行分支操作。通常情况下,不建议在分离头指针状态下工作,因为更改可能会丢失。 git checkout<commit-hash> ...
git checkout -- file;撤销对工作区修改;这个命令是以最新的存储时间节点(add和commit)为参照,覆盖工作区对应文件file;这个命令改变的是工作区 git reset HEAD -- file;清空add命令向暂存区提交的关于file文件的修改(Ustage);这个命令仅改变暂存区,并不改变工作区,这意味着在无任何其他操作的情况下,工作区中的...
git checkout [-b] <branchname> git commit 将stage区的修改提交。 git commit -m "my comments" 如果觉得刚才的提交的注释没写好,但还没有push到服务器,可以再次修改。 git commit --amend git status -s 指定以短格式输出。 git status [-s] ...
$ git checkout -- readme.txt //丢弃工作区的修改。14. 删除文件在工作区文件夹下新建一个 test.txt 文件,并添加和提交到Git, 这时候可用 rm 命令删除:$ rm test.txt 这时工作区和版本库就不一样了。现在又分两种情况:(1) 确实要从版本库中删除该文件,那就用 git rm 命令删除,并且 git commit:...
This option is only valid for the update command. Checkout the commit recorded in the superproject on a detached HEAD in the submodule. This is the default behavior, the main use of this option is to overridesubmodule.$name.updatewhen set to a value other thancheckout. If the keysubmodule...