以下是我使用git时所做的事情。 我从我的github帐户中获取了一个存储库。 我现在在本地工作区中检查分支。 我切换到这样的远程分支
git checkout remotes/origin/circular_buffer_modifications
为什么我的头脱落了?这是否表示我切换正确或头部脱离时出现错误?
结帐时使用其他名称
git checkout circular_buffer_modifications
我没有收到任何警告吗?
CPU-384U ~/acid/another_tests_github_personal/BTB: git clone https://github.com/mrigendrachaubey/back_to_basics.git
Cloning into 'back_to_basics'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 2), reused 9 (delta 2), pack-reused 0
Unpacking objects: 100% (9/9), done.
Checking connectivity... done.
CPU-384U ~/acid/another_tests_github_personal/BTB: ls
back_to_basics
CPU-384U ~/acid/another_tests_github_personal/BTB: cd back_to_basics/
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git remote -v
origin https://github.com/mrigendrachaubey/back_to_basics.git (fetch)
origin https://github.com/mrigendrachaubey/back_to_basics.git (push)
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/circular_buffer_modifications
remotes/origin/master
remotes/origin/modified
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git checkout remotes/origin/circular_buffer_modifications
Note: checking out 'remotes/origin/circular_buffer_modifications'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at df66963... [BTB_CB] Added macro MAX
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git branch
* (HEAD detached at origin/circular_buffer_modifications)
master
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git checkout circular_buffer_modifications
Branch circular_buffer_modifications set up to track remote branch circular_buffer_modifications from origin.
Switched to a new branch 'circular_buffer_modifications'
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git branch
* circular_buffer_modifications
master
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics: git branch -a
* circular_buffer_modifications
master
remotes/origin/HEAD -> origin/master
remotes/origin/circular_buffer_modifications
remotes/origin/master
remotes/origin/modified
CPU-384U ~/acid/another_tests_github_personal/BTB/back_to_basics:
我认为这些是git的非常基础,我不了解。谁能告诉我我应该遵循什么样的思维方式?
使用命令行从本地工作区创建一个新的远程分支
要创建一个新的分支以从github网页进行远程访问吗?
什么是本地分支,它如何或如何引用远程分支,所以我只能将代码推送到正确的远程分支。
HEAD是什么,起源?就像“起源”一样,是代码的“起源”。那个始发地总是一个偏僻的地方。我对这个术语的理解正确吗?
我可以阅读git的文档,但是我认为文档从来没有帮助我了解特定的问题,因为我以一种破碎的方式理解git,因为有时这些术语并不能使我获得内在的理解。
答案 0 :(得分:2)
为什么我的头脱落了?这是否表示我切换正确或头部脱离时出现错误?
因为您必须切换到本地分支(而不是远程跟踪分支),才能将HEAD视为“未分离”。
当我结帐为其他名字
git checkout circular_buffer_modifications
时,我没有得到任何警告吗?
如果未找到
<branch>
,但确实在一个具有匹配名称的远程站点(称为<remote>
)中存在跟踪分支,则将其等同于
$ git checkout -b <branch> --track <remote>/<branch>