codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
📦

Git & GitHub

38 / 63 topics
35Archiving Repositories36Deleting Repositories37Moving or Renaming Repositories38Archiving Files in a Repository
Tutorials/Git & GitHub/Archiving Files in a Repository
📦Git & GitHub

Archiving Files in a Repository

Updated 2026-04-20
3 min read

Introduction

In software development, managing files within a repository is crucial for maintaining an organized and efficient workflow. One common task is archiving files that are no longer needed but should be retained for historical or legal reasons. This tutorial will guide you through the process of archiving files in a Git repository using both Git commands and GitHub features.

Understanding Archiving

Archiving involves moving files to a separate location within the repository, often in a dedicated directory such as archived/. This keeps the main working directory clean while preserving older versions or obsolete files. Archiving is different from deleting files, as archived files can still be accessed if needed.

Prerequisites

Before you begin archiving files, ensure that:

  • You have Git installed on your local machine.
  • You have a GitHub account and access to the repository where you want to archive files.
  • You have the necessary permissions to push changes to the repository.

Archiving Files Using Git Commands

Step 1: Clone the Repository

First, clone the repository to your local machine if you haven't already:

git clone https://github.com/yourusername/your-repository.git
cd your-repository

Step 2: Create an Archive Directory

Create a directory named archived in the root of your repository:

mkdir archived

Step 3: Move Files to the Archive Directory

Move the files you want to archive into the archived/ directory. You can use the mv command for this purpose:

mv path/to/file1.txt archived/
mv path/to/file2.txt archived/

Step 4: Commit the Changes

After moving the files, commit the changes to your local repository:

git add archived/
git commit -m "Archive old files"

Step 5: Push the Changes to GitHub

Push the committed changes to the remote repository on GitHub:

git push origin main

Archiving Files Using GitHub Features

GitHub provides a user-friendly interface for managing files, including archiving.

Step 1: Navigate to Your Repository

Log in to your GitHub account and navigate to the repository where you want to archive files.

Step 2: Move Files to the Archive Directory

  1. Click on the file or folder you want to archive.
  2. Click on the "..." menu next to the file name.
  3. Select "Move" from the dropdown menu.
  4. Enter archived/ as the destination path and click "Move".

Step 3: Commit the Changes

GitHub will automatically create a commit for the move operation. You can review the commit message and make any necessary changes before committing.

Step 4: Push the Changes

The changes are pushed to GitHub automatically when you commit them through the GitHub interface.

Best Practices

  • Organize Archived Files: Use subdirectories within archived/ to categorize files by type or project phase.
  • Document Archiving Decisions: Include a README file in the archived/ directory explaining why certain files were archived and when they were moved.
  • Avoid Large Archives: If you have large binary files, consider using Git LFS (Large File Storage) to manage them separately.
  • Regularly Review Archives: Periodically review the contents of your archive to ensure it remains useful and not cluttered with unnecessary files.

Conclusion

Archiving files in a repository is an important task for maintaining a clean and organized codebase. By following the steps outlined in this tutorial, you can effectively manage obsolete or less frequently used files while keeping them accessible if needed. Whether you prefer using Git commands or GitHub's interface, both methods provide robust solutions for archiving files in your repositories.

Additional Resources

  • Git Documentation
  • GitHub Help
  • Git LFS Documentation

By mastering the art of archiving files, you'll be better equipped to manage your projects and ensure that your repositories remain efficient and well-organized.


PreviousMoving or Renaming RepositoriesNext Handling Large Repositories

Recommended Gear

Moving or Renaming RepositoriesHandling Large Repositories