git 笔记

来源:互联网 发布:周末父母 知乎 编辑:程序博客网 时间:2024/06/01 09:49

最近在看一个 git 教程, 顺便做点笔记

这是教程的链接: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000


关于删除分支

可以用 git branch -d 和git branch -D 来删除分支。关于 大写D 和小写d的区别: 如果用小写的d,则要求删除的分支已经完全被merge了; 大写的D则是强制删除。下面一段是 git 的官方说明:

-d
--delete

Delete a branch. The branch must be fully merged in its upstream branch, or inHEAD if no upstream was set with--track or--set-upstream.

-D

Shortcut for --delete --force.

-f
--force

Reset <branchname> to <startpoint> if <branchname> exists already. Without -f git branch refuses to change an existing branch. In combination with -d (or--delete), allow deleting the branch irrespective of its merged status. In combination with-m (or--move), allow renaming the branch even if the new branch name already exists.


Upstream 概念

来源:ttps://segmentfault.com/a/1190000002783245

git中存在upstream和downstream,简言之,当我们把仓库A中某分支x的代码push到仓库B分支y,此时仓库B的这个分支y就叫做A中x分支的upstream,而x则被称作y的downstream,这是一个相对关系,每一个本地分支都相对地可以有一个远程的upstream分支(注意这个upstream分支可以不同名,但通常我们都会使用同名分支作为upstream

0 0