git获取远端版本库上的Tag(没有clone[远端的版本库太⼤了])
⽅法⼀
The git fetch command delivers references (names, not raw commit-IDs) to the remote, more or less.
(More specifically, u git ls-remote remotename to e what the remote is willing to give you in terms of names.
This produces a list of SHA-1s on the left with names on the right, and the only thing your fetch can ask for is the names-on-the-right.
At which point you'll get the ID-on-the-left if the name on the remote still points to that ID, so it depends on how actively that remote gets updated.)
It is possible, in various ways, to deliver raw commit-IDs to a remote and ask that remote what is visible starting from that point,
and sometimes working backwards through history as well, but not via git fetch.
(You can u git archive but the remote can decide whether or not to allow you to access via raw commit-IDs;
or with remotes that have web rver access, including to specific commits, you can often just view the top-level contents of a commit,
and u that to "drill down", as they say, to the various pieces. But that is a very slow way to do it.)
If you'd like to u git fetch to get some particular commit, probably the easiest way to do that is to have someone with access to the remote attach a name—most likely a tag—to that commit ID.
Then you can have your git fetch bring over that refspec, and put it under any other refspec you like.
For instance, suppo you can ssh directly to whatever hosts origin:
$ igin.host 'cd /repos/repo.git; git tag temporary f1e32e1'
[enter password, etc; obrve tag created]
$ git fetch origin refs/tags/temporary:refs/heads/newbranch
[obrve fetch happen; now you have local branch 'newbranch']
$ igin.host 'cd /repos/repo.git; git tag -d temporary'
Note that the name need not be a branch, it need only be a reference you can pull over with git fetch and e with git ls-remote.
You then u a name that will match that on the left-hand-side of your refspec when fetching.
The name created in your repo is controlled by the right-hand-side of the refspec (refs/heads/newbranch in the example above).
This is also the answer to your last paragraph question: you can only name things that have names on the remote (this is partly intended to avoid "leaking" unnamed commits that remain in a repository before garbage-collection, so it's considered a feature rather than a bug). The names go on the LHS of the refspec. Your own names go on the right.
Your name on the right is assumed to be a branch or tag name (bad on what the name on the left matches, though you can explicitly spell out refs/heads/ or refs/tags/ to override it), so even is a valid SHA-1, it's treated as a branch name here—the missing name on the left transla
tes to HEAD, as missing names almost always do—and git fetch creates a branch who name is disturbingly SHA-1-ish. (Incidentally I once created a branch name that looked like an SHA-1, and later confud mylf. I forget exactly what the name was, something like de-beadwithout the hyphen. I renamed it to the hyphenated version just to make it clear I didn't mean a raw commit ID! :-) )貌似是⽆解的,远端必须给第⼀个commit起了名字,或者创建分⽀,或者Tag
才能通过fetch来获取
1. 本地初始化⼀个版本库
git init
2.添加远端
3.参照上⾯的链接处理
git ls-remote origin &
把git ls-remote origin的结果输出到的⽂件中
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
书名号怎么打出来
或者
git fetch origin v0.99
这个命令不会出错,但是本地没有代码,也找不到⽅法把代码弄出来。【因为本地⼀次提交都没有,是没有HEAD的】$ git rev-list FETCH_HEAD --count
1076
//在版本0.99的时候,⼀共有1076次提交
$ git ret --hard d6602ec5194c87b0fc87103ca4d67251c76f233a 【这个也没啥⽤】
HEAD is now at a3eb250 [PATCH] alternate object store and fsck
//HEAD的指向和master的指向是⼀致的
8d530c4d64ffcc853889f7b385f554d53db375ed HEAD
//5个分⽀
ee6ad5f4d56e697c972af86cbefdf269b386e470 refs/heads/maint时间简史作者
8d530c4d64ffcc853889f7b385f554d53db375ed refs/heads/master
c07a1e8782dadcedeffd389aa9bce4fda5b0983c refs/heads/next
9b9e9adbccf975e4ffc7af213fbf55f187e752bf refs/heads/pu汉语言文学毕业论文
49a1e5ee48904bfe562388041bdcdb3d8ad21d10 refs/heads/todo
//这些可能是合并记录
f0d0fd3a5985d5e588da1e1d11c85fba0ae132f8 refs/pull/10/head
3fed6331a38d9bb19f3ab72c91d651388026e98c refs/pull/10/merge
d604669e32e847c2ba5010c89895dd707ba45f55 refs/pull/100/head
1101dcb2eb2a20bb8009422d9760cd475c1b4590 refs/pull/100/merge
5867fc2ad19dd9dc49a9bde7704cf9cf7e539a78 refs/pull/101/head
a1fb527ff90f5df3bfb5d46e8ec5d05c66a1c824 refs/pull/101/merge
/
/这⼀串看起来似乎也是分⽀
6e41cb3e3fed66e67c91f92710be792ee001702a refs/remotes/github/html
cd2b8ae983a277fb3f3c2b2c6747b0a075af1421 refs/remotes/github/maint
e3cf854918ce6092220c9e9d43802b117618d3b5 refs/remotes/github/man
4b5eac7f03f411f75087e0b6db23caa999624304 refs/remotes/github/master
3be2039f06f131442a1ff8fe0759f05176d17143 refs/remotes/github/next
b4bcbacefc5233afca24b70b29448373293c8a4f refs/remotes/github/pu渐进式延迟退休方案
4bee7490f9dab6e968086f7c3f1f2cc02caf91f3 refs/remotes/github/todo
4b5eac7f03f411f75087e0b6db23caa999624304 refs/remotes/origin/HEAD
5723afaf3a61cef537e1f4dfa88f8faf31060ef0 refs/remotes/origin/html
b15b5b10a75e202f3f90e000925545243267cbee refs/remotes/origin/maint
e193e4189407968b3c46992e3eac60d38424286e refs/remotes/origin/man
4b5eac7f03f411f75087e0b6db23caa999624304 refs/remotes/origin/master
5a144a28891926e235a49e4850b4ec5edb6db2cc refs/remotes/origin/next
55af6ac9def8b4fc2f65f627a84451d3bf17aa12 refs/remotes/origin/pu
4bee7490f9dab6e968086f7c3f1f2cc02caf91f3 refs/remotes/origin/todo
//gitgui tag
d5aef6e4d58cfe1549adef5b436f3ace984e8c86 refs/tags/gitgui-0.10.0
3d654be48f65545c4d3e35f5d3bbed5489820930 refs/tags/gitgui-0.10.0^{}
33682a5e98adfd8ba4ce0e21363c443bd273eb77 refs/tags/gitgui-0.10.1
729ffa50f75a025935623bfc58d0932c65f7de2f refs/tags/gitgui-0.10.1^{}
ca9b793bda20c7d011c96895e9407fac2df9648b refs/tags/gitgui-0.10.2
95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/tags/gitgui-0.10.2^{}
8c178f72b54f387b84388d093a920ae45b8659dd refs/tags/gitgui-0.11.0
1c1fe1005c9dacc05a34eb892ae20ebb1904a33b refs/tags/gitgui-0.11.0^{}
//junio tag
3a1c74404d544d20c0d1f0b9c072b471a20b04c0 refs/tags/junio-gpg-pub
7214aea37915ee2c4f6369eb9dea520aec7d855b refs/tags/junio-gpg-pub^{}
//v tag
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
a3eb250f996bf5e12376ec88622c4ccaabf20ea8 refs/tags/v0.99^{}
疝气手术后注意事项f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1
78d9d414123ad6f4f522ffecbcd9e4a7562948fd refs/tags/v0.99.1^{}
c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2
2779fad61302da0fe3a24995e343ab894f32fa42 refs/tags/v0.99.2^{}
⽅法⼆仅仅检出Tag所对应的commit
本地只有⼀个commit,⽆法⽤git status,git log,git branch
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
===================⽅法⼆=============
⽅法三
这个不太可⾏,是先clone,然后再⾃动切换,还是把整个版本库弄下来了
===================⽅法三=============
⽅法四美声唱法
mkdir git6
cd git6
git init
提取Tag
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
git fetch origin v0.99
新加坡人
git tag v0.99 FETCH_HEAD
之后使⽤tortoigit 切换到Tag v0.99
在这个⽬录下,各种命令好像都⽆法执⾏了。命令和⽂件的名字貌似重复了
先⽤tortoigit在第⼀个commit上创建分⽀first 【其实可以直接创建成master】
切换到first分⽀,然后重命名分⽀为master
git branch -m first master
===2015年10⽉18⽇凌晨⼀点更新===
实战⼆:linux系统的代码获取
1.在github上新建⼀个版本库LinuxStudy
2.然后clone到本地
孩子早恋怎么办定位到的最⼩的Tag是 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
5.git fetch torvalds v2.
6.11
6.git tag v2.6.11 FETCH_HEAD
尝试checkout这个tag失败
重新fetch v2.6.12
$ git checkout v2.6.12
Checking out files: 100% (17360/17360), done.
Note: checking out 'v2.6.12'.
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_br
anch_name
HEAD is now Linux 2.6.12