branch

Show just the current branch in Git

主宰稳场 提交于 2019-12-17 00:27:51
问题 I tried looking for a special Git command for this, but I couldn't find one. Is there anything shorter or faster than the following? git branch | awk '/\*/ { print $2; }' 回答1: $ git rev-parse --abbrev-ref HEAD master This should work with Git 1.6.3 or newer. 回答2: In Git 1.8.1 you can use the git symbolic-ref command with the "--short" option: $ git symbolic-ref HEAD refs/heads/develop $ git symbolic-ref --short HEAD develop 回答3: With Git 2.22 (Q2 2019), you will have a simpler approach: git

What is a tracking branch?

旧时模样 提交于 2019-12-17 00:26:36
问题 Can someone explain a "tracking branch" as it applies to git? Here's the definition from git-scm.com: A 'tracking branch' in Git is a local branch that is connected to a remote branch. When you push and pull on that branch, it automatically pushes and pulls to the remote branch that it is connected with. Use this if you always pull from the same upstream branch into the new branch, and if you don't want to use "git pull" explicitly. Unfortunately, being new to git and coming from SVN, that

What do “branch”, “tag” and “trunk” mean in Subversion repositories?

有些话、适合烂在心里 提交于 2019-12-16 19:56:26
问题 I've seen these words a lot around Subversion (and I guess general repository) discussions. I have been using SVN for my projects the last few years, but I've never grasped the complete concept of these directories. What do they mean? 回答1: Hmm, not sure I agree with Nick re tag being similar to a branch. A tag is just a marker Trunk would be the main body of development, originating from the start of the project until the present. Branch will be a copy of code derived from a certain point in

常用Git操作

扶醉桌前 提交于 2019-12-16 16:52:09
--------------------git-------------------- 1、简介 1、Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。[1] Git的读音为/gɪt/。 2、Git是一个开源的分布式版本控制系统,可以有效、高速的处理从很小到非常大的项目版本管理。[2] Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。 2、特点 1、从服务器上克隆完整的Git仓库(包括代码和版本信息)到单机上。 2、在自己的机器上根据不同的开发目的,创建分支,修改代码。 3、在单机上自己创建的分支上提交代码。 4、在单机上合并分支。 5、把服务器上最新版的代码fetch下来,然后跟自己的主分支合并。 6、生成补丁(patch),把补丁发送给主开发者。 7、看主开发者的反馈,如果主开发者发现两个一般开发者之间有冲突(他们之间可以合作解决的冲突),就会要求他们先解决冲突,然后再由其中一个人提交。如果主开发者可以自己解决,或者没有冲突,就通过。 8、一般开发者之间解决冲突的方法,开发者之间可以使用pull 命令解决冲突,解决完冲突之后再向主开发者提交补丁。 --------------------git与SVN的对比-------------------- 1、git是分布式的,SVN不是。

git创建新分支、推送到新分支、删除本地分支精简版

对着背影说爱祢 提交于 2019-12-16 08:54:07
git branch -a 查看所有分支 git checkout -b test01 创建本地test01分支 git push --set-upstream origin test01 把本地test01分支推送到远程 once created a local branch by accident: git branch -d [branch_name] to delete it. 来源: CSDN 作者: sight23455 链接: https://blog.csdn.net/sight23455/article/details/103508837

如何列出包含给定提交的分支?

a 夏天 提交于 2019-12-16 04:23:16
如何查询 git 以找出包含给定提交的分支? gitk 通常会列出分支,除非有太多分支,在这种情况下,它只会显示“许多(38)”或类似内容。 我需要知道完整列表,或者至少要知道某些分支是否包含提交。 #1楼 从 git-branch手册页 : git branch --contains <commit> 仅列出包含指定提交的分支(如果未指定,则为HEAD)。 暗示 --list 。 git branch -r --contains <commit> 还列出 远程跟踪分支 (如下面的 user3941992 的 答案 所述),即“与远程分支有直接关系的本地分支”。 另请参阅这篇 git ready 文章。 --contains 标记将确定是否已将某个提交引入分支。 也许您已经从自己认为已应用的补丁中获得了提交SHA,或者您只是想检查是否可以将您最喜欢的开源项目提交,从而将内存使用减少了75%。 $ git log -1 tests commit d590f2ac0635ec0053c4a7377bd929943d475297 Author: Nick Quaranto <nick@quaran.to> Date: Wed Apr 1 20:38:59 2009 -0400 Green all around, finally. $ git branch --contains

Git常用命令总结

妖精的绣舞 提交于 2019-12-15 15:14:58
寄语 死记硬背命令没有任何意义,无论linux、sql还是git等,这些万年不变的命令没必要花时间花精力刻意去记,用的多了自然就记住了,根本无需去刻意记,小时候背课文、英文单词、工作了背命令?脑子不是用来干这些体力活的。 编程的真谛是思想,编程思想、解决问题思维,而不是刻板冰冷的命令,就有那么一些以死记硬背各种命令为能事,我深鄙视之,殊不知,新手程序员和老程序员差的就是编程思想、解决问题思维(恐怕很多老程序员都没有这个意识),编程语言只是解决问题的工具,我们终极目的不是编程,是解决问题!不要本末倒置了。 ================================================ 以下为转载的【 圣骑士wind 】的文章: git init 在本地新建一个repo,进入一个项目目录,执行git init,会初始化一个repo,并在当前文件夹下创建一个.git文件夹. git clone 获取一个url对应的远程Git repo, 创建一个local copy. 一般的格式是git clone [url]. clone下来的repo会以url最后一个斜线后面的名称命名,创建一个文件夹,如果想要指定特定的名称,可以git clone [url] newname指定. git status 查询repo的状态. git status -s: -s表示short,

如何比较本地git分支与其远程分支?

↘锁芯ラ 提交于 2019-12-15 14:27:11
如何查看本地分支和远程分支之间的 diff ? #1楼 第一种 git branch -a 获取可用分支列表。 在输出上你可能会看到类似的东西 * master remotes/main/master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/mt remotes/upstream/master remotes/upstream/mt 然后显示差异 git diff --stat --color remotes/main/master..origin/master git diff remotes/main/master..origin/master #2楼 要更新远程跟踪分支,您需要先键入 git fetch 然后: git diff <masterbranch_path> <remotebranch_path> 你可以 git branch -a 列出所有分支机构(本地和远程)然后选择分支的名字从名单(只是删除 remotes/ 远程分支的名字。 示例: git diff master origin/master (其中“master”是本地主分支,“origin / master”是远程,即origin和master分支。) #3楼 git diff <local

git分支以及分支合并

假装没事ソ 提交于 2019-12-14 06:11:42
git分支以及分支合并 1. 新建分支 2. 拉取分支 git pull // 拉取分支 git pull index - ajax // 拉取指定的index-ajax分支 3. 切换分支 git checkout 分支名 // 切换分支 4. 分支查看 git branch // 列出本地分支 git branch - vv // 列出本地分支与追踪关系 git branch - r // 列出远程分支 git branch - a // 列出所有分支 当前所在分支前有*标识。 5. 分支下代码提交 git add . git commit - m "swiper" git push 6. 分支合并 git checkout master // 切换至需要合并到分支 git merge origin / index - swiper // 合并远程的index-swiper分支到master分支 git push origin master // 提交至远程master分支 7. 恢复工作区 git checkout . // 恢复工作区 8. 从远程仓库获取所有分支 git branch - r | grep - v '\->' | while read remote ; do git branch -- track "${remote#origin/}" "$remote"

How push directly to remote server just using push?

两盒软妹~` 提交于 2019-12-14 03:24:57
问题 I got a remote git repository, I cloned it to my local repository, made local changes and when I push I got the message that I cant push to the master branch: [remote rejected] master -> master (branch is currently checked out) I read that if I change the branch it works, I do it and works, but I can't work like that; I need that when I push changes from local to remote repository the changes apply in the same time to the files on remote repository, I don't want to return to master branch, or