This manual will illustrate the procedure to use .gitkeep to commit & push an empty Git folder or directory!
How to Use .gitkeep to commit & push an Empty Git Folder or Directory?
To use .gitkeep to commit & push an empty Git folder or directory, first, navigate to the local directory, and create a new directory inside the repository. Then, add and move inside the created directory using the “cd” command. Next, make a “.gitkeep” file and move it back to the main directory. After that, commit modifications and push it to the remote.
To implement the above-listed steps, move ahead!
Step 1: Move to Git Directory
First, navigate to the local remote repository with the help of provided command:
Step 2: Create Directory
Next, execute the “mkdir” command to make a new directory in the Git repository
Step 3: Add Changes to Repository
Then, add all the made changes to the Git repository with the help of the following command:
Step 4: Move to Directory
After that, move into the newly created directory by executing the “cd new*” command:
Step 5: Create .gitkeep File
Now, run the “touch” command to create a “.gitkeep” file:
Step 6: Move Back to Repository
Next, revert to the Git main working repository through the below-provided command:
Step 7: Commit Changes
Finally, run the “git commit” command to update the Git repository by committing all of the added changes:
Step 8: Push Empty Directory
Lastly, push an empty directory to the remote directory using the below-stated command:
It can be seen that we have got the “Everything up-to-date” message because we have already pushed the empty directory to the specific remote(origin):
We have compiled the method to use .gitkeep to commit & push an empty Git folder or directory using easy steps.
Conclusion
To use .gitkeep to commit & push an empty Git folder or directory, first, run the “cd” command with the specified Git directory name. Then, create a new directory inside the repository. Next, add and move inside the created directory and create a “.gitkeep” file and move it back to the main directory. Lastly, commit add modifications, and push it to the Git remote repository. This tutorial explained the use of .gitkeep to commit & push an empty Git folder or directory.