Skip to content

Step 3: Create and commit an existing subdirectory in your project

Elias Ranz-Schleifer edited this page Jan 23, 2020 · 1 revision

Now that we have our repository cloned, we should create our POC working tree. We will create a folder called foo that contains a simple text file empty.txt. This file won't contain anything in it.

To achieve this we can run the following commands in our shell session.

cd submodule-poc # you can change submodule-poc to the directory you cloned your repo to
mkdir foo # this is an example subfolder
touch foo/empty.txt # example txt file that contains nothing

Once you have this you should end up with the following directory structure...

submodule-poc/
├── README.md
└── foo
    └── empty.txt

Let's commit this so that we can mimic the use case where we had an existing git repository with some history.

At this time if you do a git status you should see the following...

On branch master
Your branch is up to date with 'origin/master'.

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

	foo/

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

If this is the case then git add, git commit and git push. In the output of the git commit you'll notice that there was 1 file changed with 0 insertions/0 deletions. This is proof that it's an empty file.

$ git add foo/

$ git commit -m "Adding foo as an example directory that existed with some history."
[master d98eedf] Adding foo as an example directory that existed with some history.
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo/empty.txt

$ git push
Warning: Permanently added the RSA host key for IP address '<OMMITED>' to the list of known hosts.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 373 bytes | 373.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To github.com:EliasRanz/submodule-poc.git
   ce62406..d98eedf  master -> master

Clone this wiki locally