学习笔记之Git / Gitflow / TortoiseGit
All contents are moved to haoran119/learning-notes (github.com).
Git - Wikipedia
- https://en.wikipedia.org/wiki/Git
- Git (/ɡɪt/) is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows.
Gitflow Workflow | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
- Gitflow Workflow is a Git workflow design that was first published and made popular by Vincent Driessen at nvie. The Gitflow Workflow defines a strict branching model designed around the project release. This provides a robust framework for managing larger projects.
- Git cheat sheet | Atlassian Git Tutorial
Introducing GitFlow
- https://datasift.github.io/gitflow/IntroducingGitFlow.html
- GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team.
Pull Requests and Gitflow
- https://blog.axosoft.com/pull-requests-gitflow/?utm_campaign=GitKraken%20Promos&utm_medium=email&_hsenc=p2ANqtz--5kZ-hsMZwcIFWuqofU-Oa0iqSOfNS72XNKNaK7CpgtDt6A865oAJYYgDGwDy9KV3_VBTX1DzFJun_PtkOHa1HRm5ptQ&_hsmi=61804615&utm_content=61804282&utm_source=hs_email&hsCtaTracking=61c5ea4a-e8bd-4ffd-bdfa-7de19a1b53e1%7Cfba6e886-1dff-473b-8c6b-f5a02ebef2c2
- In my previous post, I discussed the Gitflow model and how it helps enterprises manage releases. In this post, I will be discussing pull requests and their importance in the development process.
TortoiseGit – Windows Shell Interface to Git
- https://tortoisegit.org/
- TortoiseGit provides overlay icons showing the file status, a powerful context menu for Git and much more!
TortoiseGit - Wikipedia
- https://en.wikipedia.org/wiki/TortoiseGit
- TortoiseGit is a Git revision control client, implemented as a Windows shell extension and based on TortoiseSVN. It is free software released under the GNU General Public License.
- In Windows Explorer, besides showing context menu items for Git commands, TortoiseGit provides icon overlays that indicate the status of Git working trees and files.
- It also comes with the TortoiseGitMerge utility to visually compare two files and resolve conflicts.
TortoiseGit - 维基百科,自由的百科全书
- https://zh.wikipedia.org/wiki/TortoiseGit
- TortoiseGit是一个Git版本控制客户端,作为Microsoft Windows的外壳扩展实现。它在GNU通用公共许可协议下作为自由软件发布。
Git 教程 | 菜鸟教程
如何优雅地向别人介绍Git - 机器之心
- https://mp.weixin.qq.com/s/79Aug3YQzS5-IuJlg46ukg
- 本文主题是如何向工具初学者介绍分布式版本控制系统 Git。除了了解关于 Git 的基本知识以外,大家还可以学到一些工具学习方面的东西。
- https://rachelcarmena.github.io/2018/12/12/how-to-teach-git.html
一篇文章,教你学会Git
- https://mp.weixin.qq.com/s?__biz=MzUyODg4Nzk2MQ==&mid=2247490430&idx=3&sn=b5e284cd5a5bb62da3819e29f0e29fa3&source=41#wechat_redirect
- https://www.jianshu.com/p/072587b47515
- 一、Git工作流程
- 二、常用Git命令
Git入门
- https://mp.weixin.qq.com/s/kreK2FlQ31VP2303FbpQzQ
-
版本控制介绍
-
什么是版本控制
-
为什么要版本控制
-
本地版本控制系统
-
集中化的版本控制系统
-
分布式版本控制系统
-
- 认识 Git
- Git 简史
- Git 与其他版本管理系统的主要区别
- Git 的三种状态
- Git 使用快速入门
- 获取 Git 仓库
- 记录每次更新到仓库
- 推送改动到远程仓库
- 远程仓库的移除与重命名
- 查看提交历史
- 撤销操作
- 分支
- 推荐阅读
Git原理入门解析
20 分钟教你搞懂 Git!- 机器学习算法与Python学习
- https://mp.weixin.qq.com/s/pyThc93faTz0N1gmHybFxw
- 1. 初始化
- 2. 保存对象
- 3. 更新索引
- 4. git add命令
- 5. 提交(Commit)
- 6. 完成提交
- 7. git commit命令
- 8. 分支(branch)
- 9. 更新分支
git 版本控制初学者指南
git 操作规范 - 程序猿
- https://mp.weixin.qq.com/s/gshJ7HeHVCnUjTssJYeSSw
- https://segmentfault.com/a/1190000014461898
- 一、 创建与合并分支
- 二、 解决冲突
- 三、Bug分支
- 四、版本回退
- 五、撤销修改
- 六、对于已经push的版本,进行回退
- 七、本地同步远程删除的分支
- 八、删除掉没有与远程分支对应的本地分支
- 九、查看远程库的一些信息,及与本地分支的信息
- 十、git stash临时保存本地操作
你可能会忽略的 Git 提交规范 - Linux学习
大厂 Git 提交规范
Git 分支设计规范
BEST PRACTICE
Git 12 岁了,为你送上 12 个 Git 的使用技巧! - Linux学习
- https://mp.weixin.qq.com/s/JZGmwYGp9ZGjYJfTu7SVJQ
- https://www.oschina.net/translate/12-git-tips-gits-12th-birthday
- 1. 你的 ~/.gitconfig 文件
- 2. 你的仓库的.gitconfig文件
- 3、别名
- 4. shell命令中的别名
- 5. 可视化提交图
- 6. 更优雅的强制推送(force-push)
- 7. git add -N
- 8. git add -p
- 9. git checkout -p
- 10. Rebase with command execution
- 11. 基于时间修改的指南
- 12. 全知的 reflog
10种Git技巧,让你省时省力又省心!
你可能不太会用的10个Git命令 - 机器之心
- https://mp.weixin.qq.com/s/2K8coqrcCajUtzx67jlZYg
- https://towardsdatascience.com/learn-enough-git-to-be-useful-281561eef959
20 个最常用的 Git 命令用法说明及示例
- https://mp.weixin.qq.com/s/acP4yklWYf5TwOrLB41JYg
- https://dzone.com/articles/top-20-git-commands-with-examples
工作流一目了然,动图展示 10 大 Git 命令
- https://mp.weixin.qq.com/s/xsQ_YKgPFpqxV8ju-K1BsQ
- https://dev.to/lydiahallie/cs-visualized-useful-git-commands-37p1
常用的Git命令清单
- https://mp.weixin.qq.com/s/r68M3qQ3Ed1J5ge1kLxrYQ
- https://blog.csdn.net/dqy19901103/article/details/107380601
团队开发中的 Git 实践
这有一份 Git 日常使用清单
Git 提交错了不用慌,这三招帮你修改记录
- https://mp.weixin.qq.com/s/xtol-m1QDJPlJE74cBUAeQ
- 修改最后一次提交
- 修改多个信息
- 顺序变更、合并、拆分
- 最后的最后,大家需要注意,虽然这些手段在修改记录的时候非常好用。但是如果这些 commit 已经被提交到了远程,我们是不可以直接 git push 同步的。因为 git 会校验我们提交的 hash 值,发现对不上之后会禁止我们的提交。所以如果想要提交到远程的话,只能使用 git push -f 强制覆盖。但是这是一个非常非常危险的操作,如果你 git push -f 了,没有人会知道你到底修改了什么,只建议在自己独有的分支上如此操作,一定一定要谨慎使用。
通过 .git 目录深入理解 Git!
Merging vs Rebasing
- Merging vs. Rebasing | Atlassian Git Tutorial
- Learn Git: Merging vs Rebasing
- https://blog.axosoft.com/learn-git-merging-rebasing/
- In this quick Git tutorial video, we’ll answer the question, “What’s the difference between merging and rebasing in Git?”
git-blame - Show what revision and author last modified each line of a file
git-branch - List, create, or delete branches
- https://git-scm.com/docs/git-branch#Documentation/git-branch.txt--d
- How do I delete a Git branch locally and remotely? - Stack Overflow
- https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely#targetText=Simply%20do%20git%20push%20origin,local%20branch%20ONLY!...
- Executive Summary
- $ git push --delete <remote_name> <branch_name>
- $ git branch -d <branch_name>
- Note that in most cases the remote name is origin.
- Delete Local Branch
- To delete the local branch use one of the following:
- $ git branch -d branch_name
- $ git branch -D branch_name
- Note: The -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch. You could also use -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status." [Source: man git-branch]
- Rename a local and remote branch in git – Multiple States Knowledge Base
- https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/
- 1. Rename your local branch.
- If you are on the branch you want to rename:
- $ git branch -m new-name
- If you are on a different branch:
- $ git branch -m old-name new-name
- If you are on the branch you want to rename:
- 2. Delete the old-name remote branch and push the new-name local branch.
- $ git push origin :old-name new-name
- 3. Reset the upstream branch for the new-name local branch.
- Switch to the branch and then:
- $ git push origin -u new-name
- Switch to the branch and then:
Git - git-bundle Documentation
- https://git-scm.com/docs/git-bundle
- git-bundle - Move objects and refs by archive
- $ git bundle create mybundle v1.0.0..master
Git Diff | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/saving-changes/git-diff
- Comparing files: git diff file
- $ git diff master ./diff_test.txt
- Comparing two branches
- $ git diff master new_branch
- Comparing files from two branches
- $ git diff master new_branch ./diff_test.txt
Git - git-gui Documentation
- https://git-scm.com/docs/git-gui
- git-gui - A portable graphical interface to Git
Git - gitk Documentation
- https://git-scm.com/docs/gitk
- gitk - The Git repository browser
- Git - gitk and git-gui | git Tutorial
Advanced Git Log | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/git-log
- The advanced features of git log can be split into two categories: formatting how each commit is displayed, and filtering which commits are included in the output.
- $ git log -5
- $ git log --after='2019-8-8'
Git - git-mv Documentation
- https://git-scm.com/docs/git-mv
- git-mv - Move or rename a file, a directory, or a symlink
- $ git mv old.py new.py
Git Push | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/syncing/git-push
- $ git push origin master
Resetting, Checking Out & Reverting | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting
- $ git checkout master ./rollback_test.txt
Git - git-reset Documentation
- https://git-scm.com/docs/git-reset
- git-reset - Reset current HEAD to the specified state
- $ git reset HEAD test.py
git stash - Saving Changes | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/saving-changes/git-stash
- git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on. Stashing is handy if you need to quickly switch context and work on something else, but you're mid-way through a code change and aren't quite ready to commit.
- $ git stash save "for debug use only"
- $ git stash list
- $ git pull
- $ git stash pop
How to create and apply changes in working directory ?
- Create a git patch from the changes in the current working directory - Stack Overflow
- https://stackoverflow.com/questions/5159185/create-a-git-patch-from-the-changes-in-the-current-working-directory
- If you haven't yet commited the changes, then:
$ git diff > mypatch.patch
- But sometimes it happens that part of the stuff you're doing are new files that are untracked and won't be in your
git diff
output. So, one way to do a patch is to stage everything for a new commit (git add
each file, or justgit add .
) but don't do the commit, and then:$ git diff --cached > mypatch.patch
- Add the 'binary' option if you want to add binary files to the patch (e.g. mp3 files):
$ git diff --cached --binary > mypatch.patch
- You can later apply the patch:
$ git apply mypatch.patch
- Note: You can also use
--staged
as a synonym of--cached
.
How to sync up feature branch with master branch code changes ?
- Do git rebase to pick up the master branch code changes.
- $ git fetch
- $ git checkout feature/xxx
- $ git rebase origin/master
- If any issues, fix it and continue
- $ git mergetool
- $ git rebase --continue
- $ git push -f origin feature/xxx
- git rebase | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase
- An introduction to Git merge and rebase: what they are, and how to use them
- https://www.freecodecamp.org/news/an-introduction-to-git-merge-and-rebase-what-they-are-and-how-to-use-them-131b863785f/#:~:text=Rebase%20is%20another%20way%20to,from%20one%20branch%20to%20another.
How to squash commits into one commit ?
- Do git rebase -i to squash commits interactively.
- $ git fetch
- $ git checkout feature/xxx
- $ git rebase -i HEAD~7 # change 7 to the actual number of commits
- Keep the top commit, and change others to 's' for squashing
- Git - Rewriting History
How to merge feature branch into master ?
- Swtich to feature branch and rebase
- $ git fetch
- $ git checkout feature/xxx
- # note that git rebase origin/master may mess up the branch history
- $ git rebase --preserve-merges origin/master
- $ git push -f origin feature/xxx
- Squash commits
- $ git rebase -i HEAD~7 # change 7 to the actual number of commits
- In the interactive mode, keep the top one commit, and change others from pick to s
- $ git push -f origin feature/xxx
- Swtich to master branch
- $ git checkout master
- $ git pull
- Merge feature branch
- $ git merge --no-ff feature/xxx
- Check the merge locally
- $ gitk
- If it looks wrong, reset the changes
- $ git reset --hard origin/master
- Push merge to server
- $ git push origin master
- Check git tag
- $ git fetch --tags
- $ git describe
How to merge feature branch with conflict ?
- Resolve merge conflicts - Atlassian Documentation
- Solved: How can I solve a conflict in a pull request?
- Tips : do it in VScode to just accecpt or reject conflicts for more convenient
How to restore lost commits ?
- Git Cherry Pick | Atlassian Git Tutorial
- https://www.atlassian.com/git/tutorials/cherry-pick
- $ git fetch
- $ git cherry-pick ***