Friday, March 7, 2025

1️⃣2️⃣ Git Ignore & Git Large File Storage (LFS)

 

1️⃣2️⃣ Git Ignore & Git Large File Storage (LFS)


Git provides ways to ignore unnecessary files and handle large files efficiently, ensuring your repository remains clean and optimized.



🌍 Shape Your Future with AI & Infinite Knowledge...!!

🌐 Want to Generate Text-to-Voice, Images & Videos? 👉 http://www.ai.skyinfinitetech.com 📚 Read In-Depth Tech & Self-Improvement Blogs 👉 http://www.skyinfinitetech.com ▶ Watch Life-Changing Videos on YouTube 👉 https://www.youtube.com/@SkyInfinite-Learning 🔥 Transform Your Skills, Business & Productivity – Join Us Today! 🔥



🔹 .gitignore File – Ignoring Unwanted Files

Sometimes, there are files you don’t want to track in Git, such as:
✅ Temporary files (.log, .tmp, .swp)
✅ System-generated files (.DS_Store, Thumbs.db)
✅ Compiled code (.class, .o, .exe)
✅ Environment files (.env, node_modules, venv)

You can tell Git to ignore such files by creating a .gitignore file.

1️⃣ Creating a .gitignore File

To create a .gitignore file, simply run:


touch .gitignore

Then, open it and add the files or directories to ignore:


# Ignore system files .DS_Store Thumbs.db # Ignore logs and temp files *.log *.tmp # Ignore compiled files *.o *.class


To check which ignored files exist in your repo:


git status --ignored


To apply changes after modifying .gitignore:


git rm -r --cached . git add . git commit -m "Updated .gitignore"


🔹 Handling Large Files with Git LFS

By default, Git is not designed for large binary files (such as videos, images, or large datasets). Git Large File Storage (LFS) helps manage large files without bloating your repository.

1️⃣ Installing Git LFS

Install Git LFS using:


# For Windows choco install git-lfs # For Mac brew install git-lfs # For Linux curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt install git-lfs

After installing, initialize Git LFS in your repository:

git lfs install


2️⃣ Tracking Large Files with Git LFS

To track specific file types (e.g., .psd, .mp4, .zip), use:


git lfs track "*.psd" git lfs track "*.mp4"

This creates a .gitattributes file, which Git uses to manage large files.

To check tracked files:


git lfs ls-files


3️⃣ Committing Large Files

Once tracked, commit the large files as usual:


git add .gitattributes git add largefile.mp4 git commit -m "Added large file with Git LFS" git push origin main


🔹 Benefits of Git LFS

Reduces repository size by storing only pointers to large files.
Speeds up Git operations by avoiding unnecessary file transfers.
Efficient for teams working with media, datasets, or binaries.



🔹 Best Practices

✔️ Always use .gitignore to keep your repository clean.
✔️ Use Git LFS only for large binary files.
✔️ Regularly check ignored files using git status --ignored.
✔️ Avoid tracking unnecessary files before committing.


By using .gitignore and Git LFS, you can keep your repository lightweight, clean, and efficient! 🚀





📚 Top 5 Books That Will Change Your Life!(Top 5 Life-Changing Books) 🚀


1️⃣ Atomic Habits – Build powerful habits and break bad ones!

👉 Get it here

2️⃣ The Psychology of Money – Master your financial mindset!

👉 Get it here

3️⃣ Think and Grow Rich – Unlock the secrets to wealth and success!

👉 Get it here

4️⃣ The Power of Your Subconscious Mind – Train your mind for success!

👉 Get it here

5️⃣ Rich Dad Poor Dad – Learn financial lessons the rich teach their kids!

👉 Get it here

No comments:

Post a Comment

Terraform State Deep Dive: Why it's Crucial and How to Manage It

Terraform State Deep Dive: Why it's Crucial and How to Manage It ...