Commit aee2040d authored by Marcia Ramos's avatar Marcia Ramos

Docs: clarify File Locking workflow

parent 77836aae
...@@ -3,7 +3,7 @@ stage: Create ...@@ -3,7 +3,7 @@ stage: Create
group: Source Code group: Source Code
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers" info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers"
type: reference, howto type: reference, howto
last_updated: 2020-08-10 last_updated: 2020-09-07
--- ---
# File Locking **(CORE)** # File Locking **(CORE)**
...@@ -99,7 +99,8 @@ created or updated with the following content: ...@@ -99,7 +99,8 @@ created or updated with the following content:
*.png filter=lfs diff=lfs merge=lfs -text lockable *.png filter=lfs diff=lfs merge=lfs -text lockable
``` ```
You can also register a file type as lockable without using LFS (to be able, for example, to lock/unlock a file you need a in a remote server that You can also register a file type as lockable without using LFS (to be able, for example,
to lock/unlock a file you need in a remote server that
implements the LFS File Locking API). To do that you can edit the implements the LFS File Locking API). To do that you can edit the
`.gitattributes` file manually: `.gitattributes` file manually:
...@@ -107,45 +108,50 @@ implements the LFS File Locking API). To do that you can edit the ...@@ -107,45 +108,50 @@ implements the LFS File Locking API). To do that you can edit the
*.pdf lockable *.pdf lockable
``` ```
The `.gitattributes` file is key to the process and **must**
be pushed to the remote repository for the changes to take effect.
After a file type has been registered as lockable, Git LFS will make After a file type has been registered as lockable, Git LFS will make
them read-only on the file system automatically. This means you will them read-only on the file system automatically. This means you will
need to **lock the file before editing it**. need to **lock the file** before [editing it](#edit-lockable-files).
### Lock files ### Lock files
To lock a file with Exclusive File Locking, open a terminal window in your By locking a file, you verify that no one else is editing it, and
repo and: prevent anyone else from editing the file until you’re done. On the other
hand, when you unlock a file, you communicate that you've finished editing
and allow other people to edit it.
1. To edit a file, request the lock. This verifies that no one else is editing To lock or unlock a file with Exclusive File Locking, open a terminal window
the file, and prevents anyone else from editing the file until you're done. in your repository directory and run the commands as described below.
```shell To **lock** a file:
git lfs lock path/to/file.png
```
1. When you're done, return the lock. This communicates that you finished ```shell
editing the file, and allows other people to edit the file. git lfs lock path/to/file.png
```
```shell To **unlock** a file:
git lfs unlock path/to/file.png
```
You can also unlock by file ID: ```shell
git lfs unlock path/to/file.png
```
You can also unlock by file ID (given by LFS when you [view locked files](#view-exclusively-locked-files)):
```shell ```shell
git lfs unlock --id=123 git lfs unlock --id=123
``` ```
If for some reason you need to unlock a file that was not locked by If for some reason you need to unlock a file that was not locked by
yourself, you can use the `--force` flag as long as you have **Maintainer** yourself, you can use the `--force` flag as long as you have **Maintainer**
permissions to the project: permissions to the project:
```shell ```shell
git lfs unlock --id=123 --force git lfs unlock --id=123 --force
``` ```
You can normally push files to GitLab whether they're locked or unlocked. You can normally push files to GitLab whether they're locked or unlocked.
Remind that the `.gitattributes` file must also be pushed to the remote repo.
NOTE: **Note:** NOTE: **Note:**
Although multi-branch file locks can be created and managed through the Git LFS Although multi-branch file locks can be created and managed through the Git LFS
...@@ -160,6 +166,9 @@ repo and run: ...@@ -160,6 +166,9 @@ repo and run:
git lfs locks git lfs locks
``` ```
The output lists the locked files followed by the user who locked each of them
and the files' IDs.
On the repository file tree, GitLab will display an LFS badge for files On the repository file tree, GitLab will display an LFS badge for files
tracked by Git LFS plus a padlock icon on exclusively-locked files: tracked by Git LFS plus a padlock icon on exclusively-locked files:
...@@ -171,9 +180,19 @@ NOTE: **Note:** ...@@ -171,9 +180,19 @@ NOTE: **Note:**
When you rename an exclusively-locked file, the lock is lost. You'll have to When you rename an exclusively-locked file, the lock is lost. You'll have to
lock it again to keep it locked. lock it again to keep it locked.
<!-- TODO: workflow suggestion - don't unlock until the change is in the default ### Edit lockable files
branch. Maybe this can be a follow up on practical workflows.
--> Once the file is [configured as lockable](#configure-exclusive-file-locks), it is set to read-only.
Therefore, you need to lock it before editing it.
Suggested workflow for shared projects:
1. Lock the file.
1. Edit the file.
1. Commit your changes.
1. Push to the repo.
1. Get your changes reviewed, approved, and merged.
1. Unlock the file.
## Default branch file and directory locks **(PREMIUM)** ## Default branch file and directory locks **(PREMIUM)**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment