如何推送 git 子模块中所做的更改?
How to push changes made in git submodule?
我已经...
- 创建了一个新的存储库,
- 添加了子模块
- 对子模块进行了更改...
git init
git submodule add ../../origin/subpr1/
cd subpr1/
touch hello.txt
git add hello.txt
git commit -m "hello.txt"
...现在我正在尝试将这些更改推送到。
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 240 bytes | 240.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To C:/src/lab/Git/mulliple_git/origin/subpr1
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/src/lab/git/origin/subpr1'
我错过了哪一步?
以下是 git 给我的一些建议。但是我的情况应该怎么办呢?
您的子模块似乎指向一个本地目录,该目录本身就是一个(非裸)Git 存储库/工作树。正如错误消息所解释的那样,在这种情况下默认拒绝推送,以避免与子模块自己的工作树元数据不一致。通常,子模块指向远程(和裸)存储库以避免此类问题。即,您应该在 /src/lab/git/origin/subpr1
处添加工作树的远程 URL 作为子模块,而不是 /src/lab/git/origin/subpr1
目录本身。
我已经...
- 创建了一个新的存储库,
- 添加了子模块
- 对子模块进行了更改...
git init
git submodule add ../../origin/subpr1/
cd subpr1/
touch hello.txt
git add hello.txt
git commit -m "hello.txt"
...现在我正在尝试将这些更改推送到。
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 240 bytes | 240.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To C:/src/lab/Git/mulliple_git/origin/subpr1
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/src/lab/git/origin/subpr1'
我错过了哪一步? 以下是 git 给我的一些建议。但是我的情况应该怎么办呢?
您的子模块似乎指向一个本地目录,该目录本身就是一个(非裸)Git 存储库/工作树。正如错误消息所解释的那样,在这种情况下默认拒绝推送,以避免与子模块自己的工作树元数据不一致。通常,子模块指向远程(和裸)存储库以避免此类问题。即,您应该在 /src/lab/git/origin/subpr1
处添加工作树的远程 URL 作为子模块,而不是 /src/lab/git/origin/subpr1
目录本身。