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)

dell@dell-PC ~/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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM