我试图在两个W10系统上第一次使用git 2.37.1建立一个新的独立存储库,但是由于我的新手,我找不到任何适合我的问题。:-)对不起,格式混乱,我在代码前做了4个空格,但大多数代码行出于某种原因忽略了这一点。
花了几个小时看其他类似的问题,但他们似乎都说我试图克隆的远程存储库中没有提交,这是不正确的。有很多的提交。
我在System1上创建了一个git存储库,它可以工作。
git ls-tree --full-tree --name-only -r HEAD
显示我所有的文件(包含很多提交)
git show HEAD
显示
commit 557...27d (HEAD -> master)
# and the diff between the latest and previous commit
和
git branch -a
显示
* master
没有分支,没有复杂性,什么都没有
我进入System2,创建我的repo目录,cd进去,然后
git init
git remote add origin s:/cap2office # that's my mapped System1 repository)
git pull origin master
我得到:fatal: couldn't find remote ref master
git remote
得到:origin
git branch -a
显示什么
git ls-remote
显示:From s:/cap2office
我也试过:
git clone s:/cap2office
显示
Cloning into 'cap2office'...
warning: You appear to have cloned an empty repository.
我知道我错过了一些微不足道的魔法命令,但我不知道是什么。
你不是在克隆一个仓库,你是在克隆一个git的工作目录。
git库存储在工作目录下的.git
文件夹中。
试试这个:
git remote add origin s:/cap2office/.git
在系统2上,不是执行git init
然后git remote add
和git pull
,而是这样做:
git clone s:/cap2office/.git
或者如果你在Git Bash中,有时冒号不起作用所以你需要
git clone s/cap2office/.git
然后你可以把cd
放到它被克隆的文件夹里,然后像git status
、git checkout
一样,修改东西,提交,然后推送到远程。