深圳做外贸网站公司,南阳网站seo顾问,简单做网站的价格,google chrome网页版文章目录 练习一练习二练习三练习四练习五练习六练习七 练习一 若还没有 Git 的相关经验#xff0c;阅读 Pro Git 的前几章或诸如 Learn Git Branching 的相关教程#xff0c;并在学习的同时从 Git 的数据模型#xff08;data model#xff09;的角度思考各 Git 命令。 老师… 文章目录 练习一练习二练习三练习四练习五练习六练习七 练习一 若还没有 Git 的相关经验阅读 Pro Git 的前几章或诸如 Learn Git Branching 的相关教程并在学习的同时从 Git 的数据模型data model的角度思考各 Git 命令。 老师非常建议阅读 Pro Git。
练习二 clone 该课程Missing Semester网站的仓库随后 以图的形式展现其版本历史运用 git log 加一个参数找到修改 README.md 的最后一人运用 git blame 与 git show 得到 _config.yml 中 collections: 这一行最后一次修改的 commit 信息 第 1、3 小题在 lecture 中演示过而第 2 小题据提示比较简单。 用 git clone URL folder*必备基础技能*克隆课程仓库 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise$ git clone https://github.com/missing-semester/missing-semester missing-semester
Cloning into missing-semester...
remote: Enumerating objects: 2344, done.
remote: Counting objects: 100% (1487/1487), done.
remote: Compressing objects: 100% (543/543), done.
remote: Total 2344 (delta 980), reused 964 (delta 941), pack-reused 857
Receiving objects: 100% (2344/2344), 15.61 MiB | 1.28 MiB/s, done.
Resolving deltas: 100% (1392/1392), done.不妨运用 Topic 5 所讲解的*别名 (alias)*知识简化 git log 的相关图示法命令 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/test/demo$ alias glgit log --all --graph --decorate
cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/test/demo$ alias gl1gl --oneline**提示**可以在配置文件 ~/.bashrc 中设定默认的 alias。当然本练习做到后面练习五发现可以直接修改 Git 的配置文件 .gitconfig。 gl包含详细 commit 的信息 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ gl gl_res.log
cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ vim gl_res.log结果极长共 4218 行。 gl1缩略信息每个 commit 仅一行 * d38f585 (HEAD - master, origin/master, origin/HEAD) Merge branch alexandr-gnrk/update-jupyter-binding
|\
| * f600f32 Update Vim binding for Jupyter
|/
* 2253e4e Switch recommended app to Rectangle
* 18ee93c Ignore Reddit URLs when checking links
* 2ab1b78 Merge branch alkock/master
|\
| * 98d90f8 added german translation
|/
* bd75a78 Fix broken links
* 7330a25 Merge branch fipachu/git-aliases
|\
| * 6fc734b Add more useful overview of Git aliases
|/
* f45234f Merge branch Nikitaz1410/patch-2
...部分较新的历史如上共 885 行。 提示当 git log 等其它 git 命令的信息较长时会显示前一部分信息并自动进入某种 “交互” 模式上下移动方法同 VimH 键显示帮助Q 键退出。 考虑使用 Topic 2 提及的 tldr 工具查询所需用法 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ tldr git log...Show a history of commits.More information: https://git-scm.com/docs/git-log....- Show the history of a particular file or directory, including differences:git log -p path/to/file_or_directory...由此得知 git log -p 文件/文件夹 后来发现不应该如上加上 -p flag其会显示所有 “differences”直接加文件即可 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ git log README.md
commit 9ef9db72211fefc00caaa7133b35dda4a99acccf
Author: Anish Athalye meanishathalye.com
Date: Thu Oct 27 20:28:41 2022 -0400Add Docker setup for easier development
...因此显然是授课老师 Anish Athalye 最后修改了 README.md。 lecture 中演示了。先 git blame 文件并找到目标信息对应的 commit随后 git show commit 得到其相关信息 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ git blame _config.yml
...
a88b4eac (Anish Athalye 2020-01-17 15:26:30 -0500 18) collections:
a88b4eac (Anish Athalye 2020-01-17 15:26:30 -0500 19) 2019:
...⇒ \Rightarrow ⇒ commit 哈希值为 a88b4eac cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ git show a88b
commit a88b4eac326483e29bdac5ee0a39b180948ae7fc
Author: Anish Athalye meanishathalye.com
Date: Fri Jan 17 15:26:30 2020 -0500Redo lectures as a collection
...所以对应 commit 的信息为 “Redo lectures as a collection”
练习三 为应对误将不应被 Git 管理的内容如某大文件或敏感信息commit 的情况学习 Github 上的官方文档随后模拟上述情形下删除目标文件。 学习文章知可以使用两种工具均需安装
git filter-repoBFG Repo-Cleaner更方便高效
根据相关说明操作即可。
练习四 修改某仓库中的文件随后依次 git stash、git log --all --oneline、git stash pop 巩固 git stash 的技能并思考其可能适用于在何种情况。 stash vt. 藏匿; 隐藏; 存放; 贮藏百度翻译)
lecture 中也演示过 git stash其可 “隐藏” 所做的修改并以 git stash pop 恢复。 修改 README.md 之后 git stash cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/test_git_stash$ echo **REMOVED** README.md
cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/test_git_stash$ git status
On branch master
Your branch is up to date with origin/master.Changes not staged for commit:(use git add file... to update what will be committed)(use git restore file... to discard changes in working directory)modified: README.mdno changes added to commit (use git add and/or git commit -a)git log cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/test_git_stash$ git log --all --oneline
7fca419 (refs/stash) WIP on master: d38f585 Merge branch alexandr-gnrk/update-jupyter-binding
088c991 index on master: d38f585 Merge branch alexandr-gnrk/update-jupyter-binding
d38f585 (HEAD - master, origin/master, origin/HEAD) Merge branch alexandr-gnrk/update-jupyter-binding
...可以发现在 HEAD commit 之上多了两条 commit且最后一条为 refs/stash。 用 git stash pop 恢复 cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/test_git_stash$ git stash pop
On branch master
Your branch is up to date with origin/master.Changes not staged for commit:(use git add file... to update what will be committed)(use git restore file... to discard changes in working directory)modified: README.mdno changes added to commit (use git add and/or git commit -a)
Dropped refs/stash{0} (7fca419c92d8bff936036a4ca32b277d11c1849a)
cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/test_git_stash$ git log --all --oneline | head -10
d38f585 Merge branch alexandr-gnrk/update-jupyter-binding
...直接跳出了 README.md 被更新的提示且此时 git log 已无之前新增的 commit 记录。 (说明上面的 head 命令能得到输入文件的开头若干行可见 Missing Semester - Topic 1 中关于类似的 tail 命令的讲解
★ git stash 应该在修改文件后又想看其之前的内容时非常有用。若无 git stash恐怕只能先将文件存在别处随后 git checkout -- file 丢弃修改。
练习五 在 Git 的配置文件 ~/.gitconfig 中创建 alias以便使用 git graph 便能得到 git log --all --graph --decorate --oneline 的结果。根据 https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases 用命令行创建 alias 亦可。 在 .gitconfig 文件中加入
[alias]graph log --all --graph --decorate --oneline测试如下
cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$ diff (git graph) (git log --all --graph --decorate --oneline)
cowbbyLAPTOP-UD6KDALFP:~/Missing Semester/6_Version Control(git)/exercise/missing-semester$可见两者输出完全一样。
练习六 You can define global ignore patterns in ~/.gitignore_global after running git config --global core.excludesfile ~/.gitignore_global. Do this, and set up your global gitignore file to ignore OS-specific or editor-specific temporary files, like .DS_Store. 练习七 Fork the repository for the class website, find a typo or some other improvement you can make, and submit a pull request on GitHub (you may want to look at this). Please only submit PRs that are useful (don’t spam us, please!). If you can’t find an improvement to make, you can skip this exercise.
文章转载自: http://www.morning.ydhmt.cn.gov.cn.ydhmt.cn http://www.morning.gbljq.cn.gov.cn.gbljq.cn http://www.morning.xsfny.cn.gov.cn.xsfny.cn http://www.morning.pjwrl.cn.gov.cn.pjwrl.cn http://www.morning.hgbzc.cn.gov.cn.hgbzc.cn http://www.morning.bhgnj.cn.gov.cn.bhgnj.cn http://www.morning.kwhrq.cn.gov.cn.kwhrq.cn http://www.morning.lbqt.cn.gov.cn.lbqt.cn http://www.morning.lbrrn.cn.gov.cn.lbrrn.cn http://www.morning.chzbq.cn.gov.cn.chzbq.cn http://www.morning.fylqz.cn.gov.cn.fylqz.cn http://www.morning.dfojgo.cn.gov.cn.dfojgo.cn http://www.morning.gqtw.cn.gov.cn.gqtw.cn http://www.morning.zgpgl.cn.gov.cn.zgpgl.cn http://www.morning.bpmns.cn.gov.cn.bpmns.cn http://www.morning.bpkqd.cn.gov.cn.bpkqd.cn http://www.morning.wrtxk.cn.gov.cn.wrtxk.cn http://www.morning.mnbcj.cn.gov.cn.mnbcj.cn http://www.morning.mmplj.cn.gov.cn.mmplj.cn http://www.morning.nwtmy.cn.gov.cn.nwtmy.cn http://www.morning.hwzzq.cn.gov.cn.hwzzq.cn http://www.morning.rfrnc.cn.gov.cn.rfrnc.cn http://www.morning.gpsr.cn.gov.cn.gpsr.cn http://www.morning.gtdf.cn.gov.cn.gtdf.cn http://www.morning.dqdss.cn.gov.cn.dqdss.cn http://www.morning.bfrff.cn.gov.cn.bfrff.cn http://www.morning.gwqq.cn.gov.cn.gwqq.cn http://www.morning.qjfkz.cn.gov.cn.qjfkz.cn http://www.morning.kfqzd.cn.gov.cn.kfqzd.cn http://www.morning.bpwdc.cn.gov.cn.bpwdc.cn http://www.morning.npkrm.cn.gov.cn.npkrm.cn http://www.morning.dmzzt.cn.gov.cn.dmzzt.cn http://www.morning.rybr.cn.gov.cn.rybr.cn http://www.morning.xfwnk.cn.gov.cn.xfwnk.cn http://www.morning.xcszl.cn.gov.cn.xcszl.cn http://www.morning.pwwjs.cn.gov.cn.pwwjs.cn http://www.morning.mtbth.cn.gov.cn.mtbth.cn http://www.morning.blqmn.cn.gov.cn.blqmn.cn http://www.morning.kmqwp.cn.gov.cn.kmqwp.cn http://www.morning.btpzn.cn.gov.cn.btpzn.cn http://www.morning.qjbxt.cn.gov.cn.qjbxt.cn http://www.morning.nqwkn.cn.gov.cn.nqwkn.cn http://www.morning.bzwxr.cn.gov.cn.bzwxr.cn http://www.morning.pdtjj.cn.gov.cn.pdtjj.cn http://www.morning.pmghz.cn.gov.cn.pmghz.cn http://www.morning.qbrs.cn.gov.cn.qbrs.cn http://www.morning.blqgc.cn.gov.cn.blqgc.cn http://www.morning.gjqwt.cn.gov.cn.gjqwt.cn http://www.morning.gpsr.cn.gov.cn.gpsr.cn http://www.morning.hlppp.cn.gov.cn.hlppp.cn http://www.morning.dywgl.cn.gov.cn.dywgl.cn http://www.morning.mkrqh.cn.gov.cn.mkrqh.cn http://www.morning.clccg.cn.gov.cn.clccg.cn http://www.morning.zstbc.cn.gov.cn.zstbc.cn http://www.morning.xmrmk.cn.gov.cn.xmrmk.cn http://www.morning.jfbpf.cn.gov.cn.jfbpf.cn http://www.morning.tjcgl.cn.gov.cn.tjcgl.cn http://www.morning.xkhhy.cn.gov.cn.xkhhy.cn http://www.morning.nbwyk.cn.gov.cn.nbwyk.cn http://www.morning.qsfys.cn.gov.cn.qsfys.cn http://www.morning.qhjkz.cn.gov.cn.qhjkz.cn http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn http://www.morning.xdjsx.cn.gov.cn.xdjsx.cn http://www.morning.wjhdn.cn.gov.cn.wjhdn.cn http://www.morning.hhxkl.cn.gov.cn.hhxkl.cn http://www.morning.lbfgq.cn.gov.cn.lbfgq.cn http://www.morning.tscsd.cn.gov.cn.tscsd.cn http://www.morning.mumgou.com.gov.cn.mumgou.com http://www.morning.qieistand.com.gov.cn.qieistand.com http://www.morning.rxfjg.cn.gov.cn.rxfjg.cn http://www.morning.mlbn.cn.gov.cn.mlbn.cn http://www.morning.kllzy.com.gov.cn.kllzy.com http://www.morning.qrsm.cn.gov.cn.qrsm.cn http://www.morning.kmcby.cn.gov.cn.kmcby.cn http://www.morning.ydmml.cn.gov.cn.ydmml.cn http://www.morning.rjmb.cn.gov.cn.rjmb.cn http://www.morning.mqtzd.cn.gov.cn.mqtzd.cn http://www.morning.bsrcr.cn.gov.cn.bsrcr.cn http://www.morning.pdbgm.cn.gov.cn.pdbgm.cn http://www.morning.nytpt.cn.gov.cn.nytpt.cn