summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcia Ramos <virtua.creative@gmail.com>2019-07-31 11:04:33 +0100
committerMarcia Ramos <virtua.creative@gmail.com>2019-07-31 11:18:35 +0100
commit18eae108ff67df7d09cae685f3898d6f6d00cbdc (patch)
tree1f66311246469901219c3505e32458c5048ba107
parentd8980a2c1b5f50162f3da4e3a42eaa12ca0b78c1 (diff)
downloadgitlab-ce-docs-migrate-git-lfs.tar.gz
Address Evan's reviewdocs-migrate-git-lfs
Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Apply suggestion to doc/topics/git/migrate_to_git_lfs/index.md Indentation 4 > 3 spaces
-rw-r--r--doc/topics/git/migrate_to_git_lfs/index.md144
1 files changed, 73 insertions, 71 deletions
diff --git a/doc/topics/git/migrate_to_git_lfs/index.md b/doc/topics/git/migrate_to_git_lfs/index.md
index 9b4a1c4f86a..c879e404997 100644
--- a/doc/topics/git/migrate_to_git_lfs/index.md
+++ b/doc/topics/git/migrate_to_git_lfs/index.md
@@ -7,7 +7,9 @@ last_updated: 2019-07-11
# Migrate a Git repo into Git LFS with BFG
Using Git LFS can help you to reduce the size of your Git
-repository and improve its performance, but simply adding the
+repository and improve its performance.
+
+However, simply adding the
large files that are already in your repository to Git LFS,
will not actually reduce the size of your repository because
the files are still referenced by previous commits.
@@ -33,9 +35,9 @@ own risk.
Before beginning, make sure:
- You have enough LFS storage for the files you want to convert.
- This needs to fit the files as they are now, and at all times
- in past history.
-- All the team members you share the repo with have pushed all changes.
+ Storage is required for the entire history of all files.
+- All the team members you share the repository with have pushed all changes.
+ Branches based on the repository before applying this method cannot be merged.
Branches based on the repo before applying this method cannot be merged.
To follow this tutorial, you'll need:
@@ -45,20 +47,20 @@ To follow this tutorial, you'll need:
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
and [Java Runtime Environment](https://www.java.com/en/download/manual.jsp)
(Java 7 or above) installed locally.
-- Install BFG locally:
+- BFG installed locally:
- ```bash
- brew install bfg
- ```
+ ```bash
+ brew install bfg
+ ```
-- Install Git LFS locally:
+- Git LFS installed locally:
- ```bash
- brew install git-lfs
- ```
+ ```bash
+ brew install git-lfs
+ ```
-_Note that this guide was tested on macOS Mojave. For other
-operating systems the instructions may be different._
+NOTE: **Note:**
+This guide was tested on macOS Mojave.
## Steps
@@ -66,85 +68,85 @@ Consider an example upstream project, `git@gitlab.com:gitlab-tests/test-git-lfs-
1. Back up your repository:
- Create a copy of your repository so that you can
- recover it in case something goes wrong.
+ Create a copy of your repository so that you can
+ recover it in case something goes wrong.
1. Clone `--mirror` the repo:
- Cloning with the mirror flag will create a bare repository.
- This ensures you get all the branches within the repo.
+ Cloning with the mirror flag will create a bare repository.
+ This ensures you get all the branches within the repo.
- It creates a directory called `<repo-name>.git`
- (in our example, `test-git-lfs-repo-migration.git`),
- mirroring the upstream project:
+ It creates a directory called `<repo-name>.git`
+ (in our example, `test-git-lfs-repo-migration.git`),
+ mirroring the upstream project:
- ```bash
- git clone --mirror git@gitlab.com:gitlab-tests/test-git-lfs-repo-migration.git
- ```
+ ```bash
+ git clone --mirror git@gitlab.com:gitlab-tests/test-git-lfs-repo-migration.git
+ ```
1. Convert the Git history with BFG:
- ```bash
- bfg --convert-to-git-lfs "*.{png,mp4,jpg,gif}" --no-blob-protection test-git-lfs-repo-migration.git
- ```
+ ```bash
+ bfg --convert-to-git-lfs "*.{png,mp4,jpg,gif}" --no-blob-protection test-git-lfs-repo-migration.git
+ ```
- It is scanning all the history, and looking for any files with
- that extension, and then converting them to an LFS pointer.
+ It is scanning all the history, and looking for any files with
+ that extension, and then converting them to an LFS pointer.
-1. Clean up the repo:
+1. Clean up the repository:
- ```bash
- # cd path/to/mirror/repo:
- cd test-git-lfs-repo-migration.git
- # clean up the repo:
- git reflog expire --expire=now --all && git gc --prune=now --aggressive
- ```
+ ```bash
+ # cd path/to/mirror/repo:
+ cd test-git-lfs-repo-migration.git
+ # clean up the repo:
+ git reflog expire --expire=now --all && git gc --prune=now --aggressive
+ ```
- You can also take a look on how to further [clean the repo](../../../user/project/repository/reducing_the_repo_size_using_git.md),
- but it's not necessary for the purposes of this guide.
+ You can also take a look on how to further [clean the repo](../../../user/project/repository/reducing_the_repo_size_using_git.md),
+ but it's not necessary for the purposes of this guide.
-1. Install Git LFS in the mirror repo:
+1. Install Git LFS in the mirror repository:
- ```bash
- git lfs install
- ```
+ ```bash
+ git lfs install
+ ```
-1. Unprotect the default branch, so that we can force push the
- rewritten repository:
+1. [Unprotect the default branch](../../../user/project/protected_branches.md),
+ so that we can force-push the rewritten repository:
- Navigate to your project's **Settings > Repository** and
- expand **Protected Branches**. Scroll down to locate the
- protected branches and click **Unprotect** the default
- branch, otherwise you can't force push to that branch.
+ 1. Navigate to your project's **Settings > Repository** and
+ expand **Protected Branches**.
+ 1. Scroll down to locate the protected branches and click
+ **Unprotect** the default branch.
1. Force-push to GitLab:
- ```bash
- git push --force
- ```
+ ```bash
+ git push --force
+ ```
1. Track the files you want with LFS:
- ```bash
- # cd path/to/upstream/repo:
- cd test-git-lfs-repo-migration
- # You may need to reset your local copy with upstream's `master` after force-pushing from the mirror:
- git reset --hard origin/master
- # Track the files with LFS:
- git lfs track "*.gif" "*.png" "*.jpg" "*.psd" "*.mp4" ".gitattributes" "img/"
- ```
-
- Now all existing the files you converted, as well as the new
- ones you add, will be properly tracked with LFS.
-
-1. Protect the default branch back:
-
- Navigate to your project's **Settings > Repository** and
- expand **Protected Branches**. Select the default branch
- from the **Branch** dropdown menu, and set up the
- **Allowed to push** and **Allowed to merge** rules and
- click **Protect**. For more information, read the
- [protected branches documentation](../../../user/project/protected_branches.md).
+ ```bash
+ # cd path/to/upstream/repo:
+ cd test-git-lfs-repo-migration
+ # You may need to reset your local copy with upstream's `master` after force-pushing from the mirror:
+ git reset --hard origin/master
+ # Track the files with LFS:
+ git lfs track "*.gif" "*.png" "*.jpg" "*.psd" "*.mp4" ".gitattributes" "img/"
+ ```
+
+ Now all existing the files you converted, as well as the new
+ ones you add, will be properly tracked with LFS.
+
+1. [Re-protect the default branch](../../../user/project/protected_branches.md):
+
+ 1. Navigate to your project's **Settings > Repository** and
+ expand **Protected Branches**.
+ 1. Select the default branch from the **Branch** dropdown menu,
+ and set up the
+ **Allowed to push** and **Allowed to merge** rules.
+ 1. Click **Protect**.
<!-- ## Troubleshooting