首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将工作树的全部内容推送到远程分支?

如何将工作树的全部内容推送到远程分支?
EN

Stack Overflow用户
提问于 2018-02-06 17:43:52
回答 1查看 1.6K关注 0票数 0

我正试图使用不可能平台部署Django应用程序,方法是按照https://www.aptible.com/documentation/enclave/tutorials/quickstart-guides/python/django.html上的说明。我现在有两个遥控器:

代码语言:javascript
复制
Kurts-MacBook-Pro:lucy-web kurtpeek$ git remote -v
aptible git@beta.aptible.com:lucy/web.git (fetch)
aptible git@beta.aptible.com:lucy/web.git (push)
origin  https://github.com/startwithlucy/lucy.git (fetch)
origin  https://github.com/startwithlucy/lucy.git (push)

我在一个分支,也叫aptible

代码语言:javascript
复制
Kurts-MacBook-Pro:lucy-web kurtpeek$ git status
On branch aptible
nothing to commit, working tree clean

我想将工作树的整个内容推送到master远程的aptible分支。在递归地将整个文件夹添加到存储库中。之后,我尝试了git add --allgit commit -a

代码语言:javascript
复制
Kurts-MacBook-Pro:lucy-web kurtpeek$ git commit --help
Kurts-MacBook-Pro:lucy-web kurtpeek$ git add --all
Kurts-MacBook-Pro:lucy-web kurtpeek$ git commit -am "Git add --all followed by git commit -am"
[aptible 9ea97969] Git add --all followed by git commit -am
 2 files changed, 9254 insertions(+)
 create mode 100644 docker-compose.yml
 create mode 100644 lucy-app/package-lock.json

后面跟着一个git push aptible aptible:master

代码语言:javascript
复制
Kurts-MacBook-Pro:lucy-web kurtpeek$ git push aptible aptible:master

但是,这给我提供了来自Aptible的以下错误消息:

代码语言:javascript
复制
remote: ERROR -- : No Dockerfile found. Aborting!

但是,目录中有一个Dockerfile

代码语言:javascript
复制
Kurts-MacBook-Pro:lucy-web kurtpeek$ ls Dockerfile
Dockerfile

知道为什么这个push不像预期的那样工作吗?(我还认为该项目利用了Git子树,但我不确定这是否相关)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-06 18:26:49

来自man git-commit

代码语言:javascript
复制
   -a, --all
       Tell the command to automatically stage files that have been
       modified and deleted, but new files you have not told Git about are
       not affected.

基本上,当您运行git -am ...时,这只会提交git知道有更改的文件。但是,由于您从未提交过您的Dockerfile,所以不会包含它(因为git不知道它)。

您可以从git commit -am的输出中确认这一点:只提交了docker-compose.ymllucy-app/package-lock.json

代码语言:javascript
复制
[aptible 9ea97969] Git add --all followed by git commit -am
 2 files changed, 9254 insertions(+)
 create mode 100644 docker-compose.yml
 create mode 100644 lucy-app/package-lock.json

在运行git add --all之前运行git commit -am ...实际上没有任何影响:git add --all确实会分阶段运行Dockerfile,但是当您运行git commit -am ...时,Dockerfile是不分阶段的。

要解决这个问题,不要在git commit上使用git commit标志,如下所示:

代码语言:javascript
复制
$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    Dockerfile

nothing added to commit but untracked files present (use "git add" to track)

$ git add --all

$ git commit -m 'Add Dockerfile'
[master 6296160] Add Dockerfile
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Dockerfile
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48648938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档