How to use .gitkeep?

Using .gitkeep is a simple way to ensure that empty directories are tracked by Git. Here’s how to use it:

  1. Create an Empty Directory: First, create the directory that you want to keep in your Git repository.

    mkdir path/to/your/directory
    
  2. Create a .gitkeep File: Inside the empty directory, create a file named .gitkeep. You can do this using the command line or any text editor.

    touch path/to/your/directory/.gitkeep
    
  3. Add and Commit the Changes: Add the directory and the .gitkeep file to your Git repository and commit the changes.

    git add path/to/your/directory/.gitkeep
    git commit -m "Add .gitkeep to keep the directory"
    
  4. Ignore the .gitkeep File (Optional): If you want to ignore the .gitkeep file in the future but still keep the directory, you can add it to your .gitignore:

    /path/to/your/directory/.gitkeep
    

By following these steps, you can ensure that your empty directories are tracked in your Git repository using the .gitkeep file.

0 Comments

no data
Be the first to share your comment!