🐙
Git Developer Guide
About
  • Overview
  • Scope of this book
  • Table of Content
  • 🐢Introduction to Version Control
    • What is Version Control?
    • Overview of git and it's benefits
    • Setting up Git on Different Platforms
  • 🍼Git Fundamentals
    • Initialising a new Git repository
    • Understanding the Git Workflow
    • Committing Changes and Writing Good Commit Messages
    • Viewing and Navigating Commit History
    • Git Basics - Practice Scenarios
      • Initialising a Git Repository
      • Committing Changes
      • Exploring Commit History
      • Amending and Undoing Commits
  • 🦕Working With Git
    • What is Git Branch?
    • Creating and Switching Between Branches
    • Merging Branches and Resolving Conflicts
    • Best Practices for Branch Management
    • Git Workflows
    • Git Log
    • Git Stash
    • Working with Git - Practice Scenarios
      • Creating and Switching Between Branches
      • Merging Branches and Resolving Conflicts
      • Branching Strategies in a Team Project
      • Rolling Back to a Previous Version
      • Experimenting with Feature Branches
      • Working with Stash
  • 🤝Working with Remote Repositories
    • Cloning a Repository from Remote
    • Pushing and Pulling Changes to and from Remote Repositories
    • Collaborative Workflows - Forking, Branching, and Pull Requests
    • Resolving Conflicts in a Collaborative Environment
    • Collaborating with Git - Practice Scenarios
      • Cloning a Remote Repository
      • Pushing and Pulling Changes
      • Collaborative Workflow with Forking and Pull Requests
      • Resolving Conflicts in a Pull Request
  • 🏆Advanced Git Features
    • Aliases and Custom Configurations
    • Working with Tags and Releases
    • Rewriting Commit History with Interactive Rebase
    • Utilising Git Hooks for Automation
    • Advanced Git Features - Practice Scenarios
      • Creating Custom Git Aliases
      • Working with Tags and Releases
      • Rewriting Commit History with Interactive Rebase
      • Using Git Hooks for Automated Testing
  • 😎Git in Real-World
    • Managing a Project with Multiple Contributors
    • Integrating Git with Continuous Integration, Continuous Deployment (CI, CD)
    • Versioning Assets with Git LFS (Large File Storage)
    • Deploying a Web Application using Git
    • Git In Real World - Practice Scenarios
      • Managing a Project with Multiple Contributors
      • Integrating Git with CICD Pipelines
      • Versioning Assets with Git LFS
      • Deploying a Web Application using Git
  • Git Troubleshooting
    • Common Mistakes and Pitfalls When Using Git
    • Undoing Changes with Git - Reverting and Resetting
    • Recovering Lost Commits or Branches
    • Dealing with Repository Corruption or Other Issues
  • Git Best Practices and Tips
    • Creating efficient git workflows: writing clean code for faster reviews
    • The importance of clean code in collaborative development
    • Significance of consistent naming conventions & coding Standards
    • Good code documentation for better git workflows
    • Writing meaningful git commit messages
    • Atomic commits in git & it's benefits for software teams
    • Structuring code & managing dependencies for better git workflows
    • Git branching strategies for software teams
  • Conclusion & Next Steps
    • Recap of Key Concepts and Commands
    • Further Resources for Expanding Git Knowledge
    • Encouragement and Tips for Continued Learning and Practice
  • License Considerations
Powered by GitBook
On this page
  • Setting up Git LFS Demonstrating how to set up Git LFS to track and manage large files in a repository.
  • Best Practices for Using Git LFS in a Collaborative Environment

Was this helpful?

  1. Git in Real-World
  2. Git In Real World - Practice Scenarios

Versioning Assets with Git LFS

PreviousIntegrating Git with CICD PipelinesNextDeploying a Web Application using Git

Last updated 1 year ago

Was this helpful?

Scenario

Scenario and Motivation Illustrating a scenario where a project involves versioning large files such as design assets.

In this scenario, let's consider a web development project where you need to include high-resolution images, videos, and other design assets. These files are an integral part of the project, and you want to keep track of their changes over time. However, including them directly in the Git repository would result in a significantly large repository size, making cloning, pushing, and pulling slow and inefficient.


Setting up Git LFS Demonstrating how to set up Git LFS to track and manage large files in a repository.

Step 1: Installing Git LFS

Before getting started, you need to install Git LFS on your system. Refer to the Git LFS documentation for installation instructions specific to your operating system.

Step 2: Initialising Git LFS in the Repository

Once Git LFS is installed, navigate to your project's repository and initialise Git LFS by running the following command:

git lfs install

This command sets up Git LFS globally on your system and prepares the repository for tracking large files.

Step 3: Configuring File Types to be Tracked by Git LFS

By default, Git LFS tracks files with certain extensions such as .png, .jpg, .mp4, etc.

However, you can customize which file types are tracked by creating a .gitattributes file in the repository's root directory. Open the .gitattributes file and add patterns for the file types you want to track using Git LFS. For example:

*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text

Step 4: Committing and Pushing Changes

After configuring Git LFS, commit the .gitattributes file to your repository and push it to the remote repository:

git add .gitattributes
git commit -m "Configure Git LFS for large files"
git push origin <branch-name>


Best Practices for Using Git LFS in a Collaborative Environment

Discussing considerations and best practices for using Git LFS in a collaborative environment.

  1. Educate Team Members: Ensure that all team members are aware of Git LFS and understand its usage. Share the setup instructions and best practices to avoid any confusion or mistakes.

  2. Git LFS Pointer Files: Git LFS uses pointer files to track large files, while the actual file content is stored on a Git LFS server. It's essential to treat these pointer files like regular Git files and include them in commits and pull requests.

  3. Ignore Local LFS Cache: Add the LFS cache directory (/.git/lfs/objects) to your repository's .gitignore file to prevent accidentally committing the LFS cache.

  4. Use Git LFS Locking: In a collaborative environment, it's important to prevent conflicts when multiple team members are working on the same large file simultaneously. Git LFS provides a locking mechanism to ensure exclusive access to a file during editing. Utilise this feature when required to avoid conflicts.

Git LFS is a powerful tool that allows you to seamlessly version large files in your Git repositories, improving performance and collaboration.

😎