我使用以下命令创建了一个测试存储库
mkdir test-repo
cd test-repo/
git init
Run Code Online (Sandbox Code Playgroud)
我在目录中创建了一个文件并提交了更改
echo 0 > file.txt
git add file.txt
git commit -m '0'
Run Code Online (Sandbox Code Playgroud)
我新建了一个分支用于开发
git checkout -b A
Run Code Online (Sandbox Code Playgroud)
文件现在在分支 A 中更改,在下一行添加“1”
file.txt
0
1
Run Code Online (Sandbox Code Playgroud)
致力于分支A
git add file.txt
git commit -m '1'
Run Code Online (Sandbox Code Playgroud)
在“A”中添加了一个空的新文件 file1.txt。然后承诺
git add file1.txt
git commit -m 'new file'
Run Code Online (Sandbox Code Playgroud)
现在 reflog 命令显示为
76633b7 (HEAD -> A) HEAD@{0}: commit: new file
070f015 HEAD@{1}: commit: 1
dfab60f (master) HEAD@{2}: checkout: moving from master to A
dfab60f (master) HEAD@{3}: commit (initial): 0
Run Code Online (Sandbox Code Playgroud)
现在我想将分支 A …