github(3)Git Branching
3.1 Git Branching - What a Branch Is
Git doesn't store data as a series of change sets or deltas, but instead as a series of snapshots.
Every directory root has a checksum number, every commit will point to a snapshot.
The default branch name is Git is master.As I initially make commits, you're given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.
When we create a new branch, that is doing so creates a new pointer for me to move around.
Create a branch
>git branch testing
In Git, a special pointer called HEAD will point to the local branch I am currently on.
Checkout a branch
>git checkout testing
This command will just move HEAD to point to the testing branch.
3.2 Git Branching - Basic Branching and Merging
Basic Branching
>git checkout -b issue53
Create a branch named issue53 and switched to this new branch.
Or
>git branch issue53
>git checkout issue53
Switch to master and merge the branch issue53
>git checkout master
>git merge issue53
Once we merge the branch back, we can delete the branch.
>git branch -d issue53
Basic Merging
Check out the branch we plan to merge our fix branch into.
>git checkout develop
Merge the fix branch into the develop
>git merge issue53
Basic Merge Conflicts
We may get conflict in this step.
CONFLICT(content): Merge conflict in xxxxx
Automatic merge failed; fix conflicts and then commit the result.
Check which file has conflict
>git status
I can directly use vim to merge the code. After that I use git add on each file to mark it as resolved.
>git add xxxx
Or I can use UI tool
>git mergetool
3.3 Git Branching - Branch Management
Branch Management
List all the branches
>git branch
To see the last commit on each branch
>git branch -v
There are 2 useful options. --merged and --no-merged
It will list all the branches merged to the current branch.
>git branch --merged
>git branch --no-merged
If a branch is not merged to current branch, we can not delete it with this command.
>git branch -d xxxx
We need to use command
>git branch -D xxxx
3.4 Git Branching - Branching Workflows
…snip…
3.5 Git Branching - Remote Branches
Pushing
The syntax will be >git push (remote) (branch)
>git push origin develop
Tracking Branches
This command will show all the branches, including the remotes
>git branch -a
Once I delete my branch, I need to delete the remote branch
>git push origin :branchName
3.6 Git Branching - Rebasing
…snip...
http://git-scm.com/book/en/Git-Branching-Rebasing
References:
http://git-scm.com/book/en/Git-Branching
http://git-scm.com/book/en/Git-Basics-Tagging
http://sillycat.iteye.com/blog/1423479
http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
分享到:
相关推荐
在 Learn Git Branching 中,我们可以通过游戏的方式来学习 Git 的基本命令,如 git clone、git add、git commit、git push 等。这些命令都是我们在使用 Git 过程中最常用的命令。通过游戏的方式,我们可以更容易地...
Git官方指南手册是一份详细的学习资源,它深入浅出地介绍了Git的各种功能和操作流程,特别是其中的“local branching on the cheap”部分,强调了Git在本地分支管理上的高效和便捷。 本地分支在Git中的核心地位...
第三章“Git Branching”则介绍了Git分支管理的高级技巧,这对于管理复杂的代码版本和进行协作开发尤为重要。 《Pro Git》第二版中的所有知识点都是为了帮助读者在现代软件开发的背景下,更好地使用Git这一工具。...
3. **Git内部机制**(1-git-internals.html): Git的核心原理基于SHA-1哈希值,确保数据的完整性和一致性。工作目录、暂存区(stage)和仓库是Git的三个基本概念。Git通过快照而非差异来保存文件状态,这使得回溯...
Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的...3.Get Branching 4.Git on the Server 5.Distributed Git 6.GitHub 7.Git Tools 8.Customizing Git 9.Git and Other Systems 10.Git Internals
- Clone & Branching:直接克隆仓库`git clone repo_url`,在本地创建分支开发,完成后推送到远程分支,然后在GitHub上发起Pull Request。 10. 解决冲突 在合并分支时可能会遇到冲突,Git会提示哪些文件有冲突。...
【GitHub使用教程、GitHub简介、安装、配置】 GitHub是一个全球知名的代码...在实际使用过程中,不断熟悉Git的更多命令和GitHub的高级功能,如Branching、Merging、Webhooks等,将有助于提高工作效率和团队协作能力。
8. **GitHub工作流**:学习和理解GitHub的基本工作流程,如拉取请求(Pull Request)、分支管理(Branching)、标签(Tag)和里程碑(Milestone),将有助于更高效地使用GitHub客户端。 9. **持续集成/持续部署(CI/...
Chapter 3 Getting oriented with Git Chapter 4 Making and using a Git repository Chapter 5 Using Git with a GUI Chapter 6 Tracking and updating files in Git Chapter 7 Committing parts of changes ...
分支运动 ... 对于此任务,我们希望您: 第一个人: 克隆此仓库 创建第一个分支并命名为“ bugFix1” 查找错误并修复 添加,提交和推送更改 创建拉取请求 一对一起检查错误 ...交换到第二个人,第二个人将重复上述步骤...
此外,Git还提供了分支(Branching)功能,可以创建项目的一个独立版本,便于同时处理多个功能或错误修复而不互相干扰。分支功能同样支持通过分支的合并请求(Merge Request)或者拉取请求(Pull Request)来请求...
"cloning and branching"是Git中两个重要的概念。`git clone`命令用于复制远程仓库到本地,这样你就可以开始工作了。而分支(branch)则允许你在不影响主分支(通常称为master)的情况下进行开发,`git branch`和`...
对于此任务,我们希望您: 第一个人: 克隆此仓库创建第一个分支并命名为“ bugFix1” 查找错误并修复添加,提交和推送更改创建拉取请求一对一起检查错误合并代码交换到第二个人,第二个人将重复上述步骤(将分支...
对于此任务,我们希望您: 第一个人: 克隆此仓库创建第一个分支并命名为“ bugFix1” 查找错误并修复添加,提交和推送更改创建拉取请求一对一起检查错误合并代码交换到第二个人,第二个人将重复上述步骤(将分支...
- **Branching Strategies**: Different branching models exist, such as Git Flow, Feature Branch Workflow, and Trunk-Based Development. Choose a strategy that fits the team's needs and project ...
7. **Git工作流**:可能会介绍一些常见的Git工作流,如GitHub Flow或GitFlow,它们定义了不同的分支策略以适应不同类型的项目需求。 8. **冲突解决**:当多个开发者修改同一部分代码时,如何识别和解决合并冲突。 ...
This serves as a primer for the topics to follow such as branching and merging, creating and managing a GitHub personal repository, and fork and pull requests. You'll also learn how to migrate from ...