Here is a step-by-step guide to add a .gitignore file directly inside GitHub Desktop:
Step 1: Open Repository Settings
- Once the repository is created, but before you commit & push the first time Go to the “Repository” menu at the top and select Repository Settings.
- In the Repository Settings window, click on the Ignored Files tab.
- This is where you can add files and directories that you want Git to ignore.
Step 4: Add Entries to .gitignore
- In the Ignored Files tab, add the files, directories, or patterns you want Git to ignore.
- For example, you should add:
/bin/
.classpath
.project
.DS_Store
- Each line represents a different file, folder, or pattern to ignore.
- Once you’re done adding the entries, click Save.
Step 5: Commit the .gitignore File
- After adding ignored files in the repository settings, GitHub Desktop will automatically create a
.gitignore file.
- In the Changes tab, you will see that a new
.gitignore file has been created and listed as a change.
- Enter a commit message (e.g., “Add .gitignore”).
- Click Commit to master/main to save the
.gitignore file to the repository.
Step 6: Push Changes to GitHub
- After committing the
.gitignore file, click Push origin to upload your changes to the remote repository on GitHub.
Step 7: Verify on GitHub
- Go to your repository on GitHub.com.
- You should see the
.gitignore file listed, and files added to .gitignore will no longer be tracked in the repository.
Summary:
- After you create a new repository in GitHub Desktop.
- Open repository settings and add files to ignore directly through GitHub Desktop under Ignored Files.
- Commit and push the
.gitignore without leaving GitHub Desktop.
The following videos in the coursework cover GitIgnore:
Unit 3-4 Java Basics:
Lesson 2: Quick Git Talk (git ignore starts at 2 min mark)
Quick Git Talk
The BEST video is the Assignment GitHub Prep (start at 8 minute mark)
After Lesson 10:
Assignment GitHub Prep