-1

I have some commits in git.

I'd like to commit all of them at once.

I tried following command

git push origin develop

It seems I could push only latest local commit.

Are there any way to commit all the local commit ?

$ git status

On branch event-api
Your branch is up to date with 'origin/develop'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   api/Dockerfile
        modified:   api/package-lock.json
        modified:   api/package.json
        modified:   api/src/user/user.controller.ts
        modified:   api/src/user/user.service.ts

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        api/.env

no changes added to commit (use "git add" and/or "git commit -a")

$ git log

commit e06b782c44a0c4ffb91b64d95744323e6cb5a40e (HEAD -> event-api, origin/event-api, origin/develop, foo-event-api)
Author: hikaru 
Date:   Sun Sep 20 23:57:36 2020 +0900

    Revert "user.entity.ts"
    
    This reverts commit 38e3ac8a623d70ee89c41226d796fb4753cca10b.

commit 38e3ac8a623d70ee89c41226d796fb4753cca10b
Author: hikaru 
Date:   Sun Sep 20 22:49:39 2020 +0900

    user.entity.ts

commit 11d166321a5831c01a491358d6afa1be4020bbfb
Author: hikaru 
Date:   Sun Sep 20 22:40:51 2020 +0900

    add app.module.ts

commit 38eb630546eed370619b1f5178f949df99bbda07
Author: hikaru 
Date:   Sun Sep 20 22:38:12 2020 +0900

    add event

commit 8dec7bc37c539f35aa03cf3188b7adb104e1a91f
Author: hikaru
Date:   Sun Sep 20 22:36:37 2020 +0900

    add repository

Thanks

Heisenberg
  • 4,787
  • 9
  • 47
  • 76
  • 3
    Why do you think that only the last commit is pushed? All local commits that have been made since the last pull are pushed to the master. – flaxel Sep 20 '20 at 14:48
  • When I saw github, there is one file to be changed. I changed 5 files and I committed each of them. Therefore in my opinion I need to summarize them. as I am beginner if some other good way exist, please let me know. – Heisenberg Sep 20 '20 at 15:10
  • 1
    It seems you don’t have any idea what git is? https://git-scm.com/book/en/v2 is excellent. – matt Sep 20 '20 at 15:19
  • What is your output if you type: `git status`? You do not need to merge commits. Just to make sure I got it right. You have edited five files in a row and made one commit each. And if you want to push the commits, only the last commit is pushed. Can you post an image of your problem or something else. Maybe [this post](https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide/320140) is helpful for you. – flaxel Sep 20 '20 at 15:20
  • Please provide a [mcve] and add your actual observations, not just your interpretations. You can not possibly push a commit without pushing all its parent commits. – Ulrich Eckhardt Sep 20 '20 at 19:31

1 Answers1

0

The git status command shows that you have modified five files. But you have not yet created any commits. If you want to create a commit per file and push it into the repository, you need to execute the following lines:

git add api/Dockerfile
git commit -m "your message"
git push

If you want to push all modified changes you can use the following commands:

git commit -a
git push
flaxel
  • 4,173
  • 4
  • 17
  • 30
  • 2
    `git commit -a` doesn't "push all modified changes". I think what you mean is instead of `git add ...` you can use `git commit -a` to commit everything that is modified. Note: this does not add files that are not being tracked already. – John Szakmeister Sep 20 '20 at 21:27