gitaptible

How to push the entire content of a working tree to a remote branch?


I'm trying to deploy a Django app using the Aptible platform by following the instructions on https://www.aptible.com/documentation/enclave/tutorials/quickstart-guides/python/django.html. I currently have two remotes:

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)

I'm on a branch which is also called aptible:

Kurts-MacBook-Pro:lucy-web kurtpeek$ git status
On branch aptible
nothing to commit, working tree clean

I would like to push the entire contents of the working tree to the master branch of the aptible remote. Following Recursively add the entire folder to a repository, I tried a git add --all followed by a git commit -a,

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

followed by a git push aptible aptible:master:

Kurts-MacBook-Pro:lucy-web kurtpeek$ git push aptible aptible:master

However, this is giving me the following error message from Aptible:

remote: ERROR -- : No Dockerfile found. Aborting!

There is, however, a Dockerfile in the directory:

Kurts-MacBook-Pro:lucy-web kurtpeek$ ls Dockerfile
Dockerfile

Any idea why this push is not working as expected? (I also believe that the project makes use of Git subtrees, though I'm not sure whether this is relevant).


Solution

  • From man git-commit:

       -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.
    

    Basically, when you run git -am ..., this only commits files git knows about that you have changes in. However, since you never committed your Dockerfile, that does not get included (because git does not know abut it).

    You can confirm this from the output of git commit -am: only docker-compose.yml and lucy-app/package-lock.json were committed:

    [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
    

    Running git add --all before running git commit -am ... actually has no impact whatsoever: git add --all does stage the Dockerfile, but when you run git commit -am ..., the Dockerfile is unstaged.

    To fix this, don't use the -a flag on git commit, like this:

    $ 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