本 Wiki 开启了 HTTPS。但由于同 IP 的 Blog 也开启了 HTTPS,因此本站必须要支持 SNI 的浏览器才能浏览。为了兼容一部分浏览器,本站保留了 HTTP 作为兼容。如果您的浏览器支持 SNI,请尽量通过 HTTPS 访问本站,谢谢!
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版上一修订版两侧同时换到之后的修订记录 | ||
software_dev:ver_ctrl:git [2023/12/12 00:24] – [References] codinghare | software_dev:ver_ctrl:git [2023/12/15 00:53] – [Tagging] codinghare | ||
---|---|---|---|
行 119: | 行 119: | ||
\\ \\ | \\ \\ | ||
这个命令避免了将未完成的文件进行 commit 的情形。该临时暂存的档案可以建立多个,可以通过 '' | 这个命令避免了将未完成的文件进行 commit 的情形。该临时暂存的档案可以建立多个,可以通过 '' | ||
+ | <code bash> | ||
+ | # saving the WIP | ||
+ | git stash | ||
+ | |||
+ | # revert the WIP but keep the saving | ||
+ | git stash apply | ||
+ | # delete the save file | ||
+ | git stash drop | ||
+ | |||
+ | # revert the WIP and delete the save file | ||
+ | git stash pop | ||
+ | </ | ||
===temp=== | ===temp=== | ||
* **git <color # | * **git <color # | ||
行 195: | 行 207: | ||
</ | </ | ||
这一段代表了当前 '' | 这一段代表了当前 '' | ||
+ | ===Tagging=== | ||
+ | git 中可以对指定的分支做 tag: | ||
+ | <code bash> | ||
+ | # switch to the branch before tagging | ||
+ | git tag < | ||
+ | |||
+ | # listing exsiting tag | ||
+ | git tag | ||
+ | |||
+ | #deleting tag | ||
+ | git tag -d < | ||
+ | |||
+ | #deleting tag on origin | ||
+ | git tag -d < | ||
+ | it push origin : | ||
+ | </ | ||
+ | 默认的 tag 是关联到当前分支的**最新** commit 上的。如果希望对指定的 commit 打 tag (比如忘记打了),需要加上 commit id: | ||
+ | <code bash> | ||
+ | git tag < | ||
+ | |||
+ | # creating tag with extra message | ||
+ | git tag < | ||
+ | |||
+ | </ | ||
+ | 打好 tag 以后就可以很方便根据 tag 查看 commit 了: | ||
+ | <code bash> | ||
+ | git show < | ||
+ | </ | ||
+ | tag 默认存在本地。如果要推送到远程,使用以下命令: | ||
+ | <code bash> | ||
+ | git push origin < | ||
+ | |||
+ | #push all tags at once | ||
+ | git push origin --tags | ||
+ | </ | ||
===Teamwork=== | ===Teamwork=== | ||
在多人使用 git 进行合作中,一般会需要: | 在多人使用 git 进行合作中,一般会需要: | ||
行 224: | 行 271: | ||
#push your branch feature to the remote | #push your branch feature to the remote | ||
git push origin your_branch_name | git push origin your_branch_name | ||
+ | |||
+ | #fetch and merge the newest master | ||
+ | git pull origin master | ||
+ | </ | ||
+ | ==git rebase== | ||
+ | 我们在 push 的时候,如果 origin 对应分支已经发生了改变(别人提交过了),那么需要用 fetch/merge 或是 pull 来同步 origin 中的新内容到本地分支。但这样做的问题在于,我们在本地的 commits 实际上处于 pull commit 之后了,那么从路径上来说我们的 commit 之于 master 的新内容之前。这样顺序是不对的。 | ||
+ | \\ \\ | ||
+ | '' | ||
+ | <code bash> | ||
+ | # before | ||
+ | |\ | ||
+ | | * d662d56 (origin/ | ||
+ | * | 30bcffe modified hello2.py | ||
+ | * | 9091cc7 add hello2.py | ||
+ | |/ | ||
+ | |||
+ | # after git rebase | ||
+ | |||
+ | * 280680e (HEAD -> master) modified hello2.py | ||
+ | * 8337019 add hello2.py | ||
+ | * d662d56 (origin/ | ||
+ | |||
+ | #after push | ||
+ | * 280680e (HEAD -> master, origin/ | ||
+ | * 8337019 add hello2.py | ||
+ | * d662d56 Update readme.md.txt | ||
</ | </ | ||
==git clone== | ==git clone== | ||
行 247: | 行 320: | ||
# -u: push the new data and link the local branch to the cloud branch | # -u: push the new data and link the local branch to the cloud branch | ||
git push -u origin master | git push -u origin master | ||
+ | </ | ||
+ | ===Tips=== | ||
+ | ==误回滚回复== | ||
+ | 如果知道想回滚版本的 hash: | ||
+ | <code bash> | ||
+ | git reset --hard hash | ||
+ | </ | ||
+ | 如果不知道: | ||
+ | <code bash> | ||
+ | #find the hash | ||
+ | git reflog | ||
+ | #backtrack | ||
+ | git reset --hard hash | ||
+ | </ | ||
+ | ==将 master 上修复的 bug 同步合并到 dev 上== | ||
+ | 这种情况一般出现在: | ||
+ | * 你正在开发新的东西 | ||
+ | * 当前的 master 分支出现了 Bug 并被修复了 | ||
+ | 这种情况下,无需去 dev 分支上再把 bug 修改一遍,只需在 dev 分支上使用如下命令即可合并 Bug 修复内容到 dev: | ||
+ | <code bash> | ||
+ | git cherry-pick < | ||
</ | </ | ||
====Git Hub==== | ====Git Hub==== | ||
行 333: | 行 427: | ||
git config core.filemode false | git config core.filemode false | ||
</ | </ | ||
- | ==误回滚回复== | + | |
- | 如果知道想回滚版本的 hash: | + | |
- | <code bash> | + | |
- | git reset --hard hash | + | |
- | </ | + | |
- | 如果不知道: | + | |
- | <code bash> | + | |
- | #find the hash | + | |
- | git reflog | + | |
- | # | + | |
- | git reset --hard hash | + | |
- | </ | + | |
====References==== | ====References==== | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||