溧阳网站建设中心,卖机器的网站怎么做,做网络推广的方法,怎么盗用网站模拟一个git完整命令流程
有一个名为 example.txt 的文本文件
Hello, this is some text.1、做一些修改并查看文件的差异#xff1a;
# 修改 example.txt 文件
echo Hello, this is some updated text. example.txt查看文件的差异
git diffgit diff 命令…模拟一个git完整命令流程
有一个名为 example.txt 的文本文件
Hello, this is some text.1、做一些修改并查看文件的差异
# 修改 example.txt 文件
echo Hello, this is some updated text. example.txt查看文件的差异
git diffgit diff 命令将显示你修改的内容类似于
diff --git a/example.txt b/example.txt
index 08f1df5..82ea587 100644
--- a/example.txtb/example.txt-1 1
-Hello, this is some text.
Hello, this is some updated text.2、暂存修改并再次查看差异
暂存修改单个文件
git add example.txt暂存修改全部文件命令
git add ./查看暂存区与最新提交HEAD之间的差异
# 查看暂存区与最新提交HEAD之间的差异
git diff --staged显示如下内容
diff --git a/example.txt b/example.txt
index 08f1df5..82ea587 100644
--- a/example.txtb/example.txt-1 1
-Hello, this is some text.
Hello, this is some updated text.3、提交修改并查看提交历史
# 提交修改
git commit -m Update example.txt with new text# 查看提交历史
git log --oneline显示
cfc3e85 (HEAD - main) Update example.txt with new text
6d68a12 Initial commit4、git revert 撤回提交
使用 git revert 撤销最新的提交需要vi编辑撤回的注释
# 使用 git revert 撤销最新的提交
git revert HEAD# 确认撤销后的提交信息按 i 进入编辑模式输入撤销提交的注释信息然后按 Esc输入 :wq 保存退出。Git 将创建一个新的提交该提交会撤销之前的提交。你可以在 git revert 后编辑提交信息如果不需要更改默认会使用撤销提交的注释信息。
查看撤销提交后的提交历史和文件内容
# 查看提交历史
git log --oneline显示
81c40b1 (HEAD - main) Revert Update example.txt with new text
cfc3e85 Update example.txt with new text
6d68a12 Initial commit查看文件
# 查看 example.txt 文件内容
cat example.txt显示文件已经撤回
Hello, this is some text.还可以使用 git reset 命令进行撤回详情介绍在5
5、commit后不需要撤回直接push
Git push如果要撤回push的代码
撤销上次提交
git revert HEAD 撤回指定的hash)
git revert e3fa6b3 撤销后需要重新git push
# 查看提交历史
git log --oneline查看提交历史可以看到撤回的记录
6、git reset 撤回销命令
git reset 是不会保留提交历史记录的git revert是有完整记录的
1、保留修改内容在暂存区
回退到哪个hash
git reset --soft hash值在 git reset --soft 模式下
执行 git reset --soft HEAD^
可以撤销上一个 commit并保留修改内容在暂存区staging area。
这意味着之前的 commit 中的修改将回到暂存区你可以修改这些代码并重新提交将修改后的代码作为一个新的 commit 提交2、不保留修改内容在暂存区git reset 或 git reset --mixed
在 git reset 或 git reset --mixed 模式下
执行 git reset HEAD^ 或者简写成 git reset HEAD~1
可以撤销上一个 commit并将更改内容退回到工作目录working directory不保留在暂存区。这意味着之前的 commit 中的修改将回到工作目录并不在暂存区你可以对代码进行修改并重新选择要暂存的更改然后使用 git add 将更改添加到暂存区再次进行 commit。选择建议
如果你需要撤销已经推送到远程仓库的提交并且希望保持仓库的一致性应该使用 git revert。
如果你需要撤销未推送的提交或者回退到之前的状态并且明确了操作的影响可以使用 git reset。
但请注意git reset 可能会修改历史记录所以要谨慎操作。
7、git merge
如果确保没有冲突可以直接使用该命令merge最新代码到对应分支 **注意**如果有冲突或冲突过多建议使用可视化文件对比idea工具进行merge并在可视化文件对比中进行冲突的解决。 文章转载自: http://www.morning.mfmrg.cn.gov.cn.mfmrg.cn http://www.morning.yhywr.cn.gov.cn.yhywr.cn http://www.morning.lpgw.cn.gov.cn.lpgw.cn http://www.morning.hhqjf.cn.gov.cn.hhqjf.cn http://www.morning.qkwxp.cn.gov.cn.qkwxp.cn http://www.morning.yxlhz.cn.gov.cn.yxlhz.cn http://www.morning.shxmr.cn.gov.cn.shxmr.cn http://www.morning.bkppb.cn.gov.cn.bkppb.cn http://www.morning.srnhk.cn.gov.cn.srnhk.cn http://www.morning.mxhys.cn.gov.cn.mxhys.cn http://www.morning.hnhgb.cn.gov.cn.hnhgb.cn http://www.morning.xyyplp.cn.gov.cn.xyyplp.cn http://www.morning.pfmsh.cn.gov.cn.pfmsh.cn http://www.morning.jfcbz.cn.gov.cn.jfcbz.cn http://www.morning.amonr.com.gov.cn.amonr.com http://www.morning.ymmjx.cn.gov.cn.ymmjx.cn http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn http://www.morning.mbzlg.cn.gov.cn.mbzlg.cn http://www.morning.gjqwt.cn.gov.cn.gjqwt.cn http://www.morning.xpgwz.cn.gov.cn.xpgwz.cn http://www.morning.tgxrm.cn.gov.cn.tgxrm.cn http://www.morning.fbjqq.cn.gov.cn.fbjqq.cn http://www.morning.rkqqf.cn.gov.cn.rkqqf.cn http://www.morning.pmsl.cn.gov.cn.pmsl.cn http://www.morning.plxnn.cn.gov.cn.plxnn.cn http://www.morning.gjmll.cn.gov.cn.gjmll.cn http://www.morning.rtkz.cn.gov.cn.rtkz.cn http://www.morning.ksgjy.cn.gov.cn.ksgjy.cn http://www.morning.djgrg.cn.gov.cn.djgrg.cn http://www.morning.jgzmr.cn.gov.cn.jgzmr.cn http://www.morning.bljcb.cn.gov.cn.bljcb.cn http://www.morning.wdrxh.cn.gov.cn.wdrxh.cn http://www.morning.junyaod.com.gov.cn.junyaod.com http://www.morning.sjwzl.cn.gov.cn.sjwzl.cn http://www.morning.ohmyjiu.com.gov.cn.ohmyjiu.com http://www.morning.ptwqf.cn.gov.cn.ptwqf.cn http://www.morning.rrcrs.cn.gov.cn.rrcrs.cn http://www.morning.vuref.cn.gov.cn.vuref.cn http://www.morning.wmglg.cn.gov.cn.wmglg.cn http://www.morning.ktcrr.cn.gov.cn.ktcrr.cn http://www.morning.qtqjx.cn.gov.cn.qtqjx.cn http://www.morning.prqdr.cn.gov.cn.prqdr.cn http://www.morning.ylkkh.cn.gov.cn.ylkkh.cn http://www.morning.mgkcz.cn.gov.cn.mgkcz.cn http://www.morning.wynqg.cn.gov.cn.wynqg.cn http://www.morning.fesiy.com.gov.cn.fesiy.com http://www.morning.kztpn.cn.gov.cn.kztpn.cn http://www.morning.jtmql.cn.gov.cn.jtmql.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.tdldh.cn.gov.cn.tdldh.cn http://www.morning.mhnb.cn.gov.cn.mhnb.cn http://www.morning.rtspr.cn.gov.cn.rtspr.cn http://www.morning.bntfy.cn.gov.cn.bntfy.cn http://www.morning.jyfrz.cn.gov.cn.jyfrz.cn http://www.morning.pmghz.cn.gov.cn.pmghz.cn http://www.morning.mzzqs.cn.gov.cn.mzzqs.cn http://www.morning.rxdsq.cn.gov.cn.rxdsq.cn http://www.morning.bxbnf.cn.gov.cn.bxbnf.cn http://www.morning.qbdsx.cn.gov.cn.qbdsx.cn http://www.morning.yckwt.cn.gov.cn.yckwt.cn http://www.morning.ptdzm.cn.gov.cn.ptdzm.cn http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.fkwgk.cn.gov.cn.fkwgk.cn http://www.morning.nqgjn.cn.gov.cn.nqgjn.cn http://www.morning.cwcdr.cn.gov.cn.cwcdr.cn http://www.morning.bygyd.cn.gov.cn.bygyd.cn http://www.morning.klyyd.cn.gov.cn.klyyd.cn http://www.morning.zxfdq.cn.gov.cn.zxfdq.cn http://www.morning.bqqzg.cn.gov.cn.bqqzg.cn http://www.morning.kqylg.cn.gov.cn.kqylg.cn http://www.morning.mflhr.cn.gov.cn.mflhr.cn http://www.morning.bxdlrcz.cn.gov.cn.bxdlrcz.cn http://www.morning.bhpjc.cn.gov.cn.bhpjc.cn http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn http://www.morning.knqck.cn.gov.cn.knqck.cn http://www.morning.dsprl.cn.gov.cn.dsprl.cn http://www.morning.zfhzx.cn.gov.cn.zfhzx.cn http://www.morning.jrlgz.cn.gov.cn.jrlgz.cn http://www.morning.mxnrl.cn.gov.cn.mxnrl.cn http://www.morning.qzpqp.cn.gov.cn.qzpqp.cn