2

I have setup git to my project to push modifications to gitlab repository.

I installed a plugin from github which lies in /vendor/dereuromar/cakephp-queue

There is also a .git directory and other files associated with git in the plugin's directory

When I push my project to gitlab, everything pushes except this directory.

When trying git status it gives error as

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   vendor/dereuromark/cakephp-queue (modified content, untracked content)

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

I tried removing .git directory, .gitignore and .gitattributes directory from vendor/dereuromark/cakephp-queue.

The output of git status is

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

But the contents of that directory is not uploaded to gitlab.

How can I push the content of this directory? I have not created any submodule.

Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
  • You have a fundamental misunderstanding of how submodules work. I recommend reading the section in [Pro Git](https://git-scm.com/book/en/v2/Git-Tools-Submodules) that explains submodules, as well as the documentation: managing working tree changes with submodules is a complex task. – Pockets Jun 05 '17 at 07:24
  • I said, I haven't created any submodule. The plugin directory since contains `.git` directory, is being treated as submodule. – Anuj TBE Jun 05 '17 at 07:42
  • seems that you've missed the concept of GIT. You cannot commit the .git folder since it is the management folder of the repository and it is per clone of it and it is not part of the repository managed and distributed by GIT. – yorammi Jun 05 '17 at 09:22
  • What after deleting `.git` folder. I have deleted all git related files from that directory. Even it is not working. – Anuj TBE Jun 05 '17 at 09:24
  • 1
    You do *have* a submodule, even if you did not create one yourself. That in turn means that you have what Git calls a "gitlink" entry in the superproject. The superproject does not contain the entire code of the submodule; it contains only the hash ID of the submodule's top level commit (plus the auxiliary information in `.gitmodules` to allow Git to locate and clone the submodule). – torek Jun 05 '17 at 14:40
  • The fact that `git status` *says you have a submodule* makes it blindingly obvious you have one. Please do yourself a favor and again, read up on submodules and the documentation for the relevant Git commands, because right now, it is very clear that you do **not** understand how submodules work. – Pockets Jun 06 '17 at 00:53

1 Answers1

2

You cannot push anything that hasn't been committed yet. The order of operations is:

  1. Make your change.
  2. git add - this stages your changes for committing
  3. git commit - this commits your staged changes locally
  4. git push - this pushes your committed changes to a remote

If you push without committing, nothing gets pushed. If you commit without adding, nothing gets committed. If you add without committing, nothing at all happens, git merely remembers that the changes you added should be considered for the following commit.

The message you're seeing (your branch is ahead by 1 commit) means that your local repository has one commit that hasn't been pushed yet.

In other words: add and commit are local operations, push, pull and fetch are operations that interact with a remote.

Since there seems to be an official source control workflow in place where you work, you should ask internally how this should be handled.

Bilal Ahmed
  • 4,005
  • 3
  • 22
  • 42