git: fatal: Not a git repository (or any of the parent directories): .git
Posted alxe_yu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git: fatal: Not a git repository (or any of the parent directories): .git相关的知识,希望对你有一定的参考价值。
在看书 FlaskWeb开发:基于Python的Web应用开发实战 时,下载完源码后 git clone https://github.com/miguelgrinberg/flasky.git
试着 切换到 提交历史 1a, $ git checkout 1a,出现error:
fatal: Not a git repository (or any of the parent directories): .git
这个提示表明现在不在一个git repository目录下,需要切换到flasky下面:
$ pwd
/c/Users/dell/Documents/GitHub/flasky
然后执行即可:
$ git checkout 1a
Note: checking out ‘1a‘.
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 7e1e156... Chapter 1: initial version (1a)
[email protected] ~/Documents/GitHub/flasky ((1a))
1、git tag -a ‘tag1‘ -m ‘备注tag1‘ HEAD //在本地代码的地方新增一个标签
2、git push origin tag1 //把到这个标签的代码push到仓库中
3、git show tag1 //查看标签内容
4、git tag //查看有哪些标签
5、git tag -d tag1 //删除标签
Git跟其它版本控制系统一样,可以打标签(tag), 作用是标记一个点为一个版本号,如0.1.3, v0.1.7, ver_0.1.3.在程序开发到一个阶段后,我们需要打个标签,发布一个版本,标记的作用显而易见。
下面介绍一下打标签,分享标签,移除标签的操作命令。
打标签
git tag -a 0.1.3 -m “Release version 0.1.3″
详解:git tag 是命令
-a 0.1.3是增加 名为0.1.3的标签
-m 后面跟着的是标签的注释
打标签的操作发生在我们commit修改到本地仓库之后。完整的例子
git add .
git commit -m “fixed some bugs”
git tag -a 0.1.3 -m “Release version 0.1.3″
分享提交标签到远程服务器上
git push origin master
git push origin --tags
–tags参数表示提交所有tag至服务器端,普通的git push origin master操作不会推送标签到服务器端。
删除标签的命令
git tag -d 0.1.3
删除远端服务器的标签
git push origin :refs/tags/0.1.3
以上是关于git: fatal: Not a git repository (or any of the parent directories): .git的主要内容,如果未能解决你的问题,请参考以下文章
git解决 fatal: not in a git directory
git解决 fatal: not in a git directory
git --解决fatal: Not a git repository
fatal: Not a git repository Stopping at filesystem boundary
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git