Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/topics/git')
-rw-r--r--doc/topics/git/bisect.md6
-rw-r--r--doc/topics/git/cherry_picking.md2
-rw-r--r--doc/topics/git/feature_branch_development.md12
-rw-r--r--doc/topics/git/feature_branching.md6
-rw-r--r--doc/topics/git/getting_started.md6
-rw-r--r--doc/topics/git/git_add.md6
-rw-r--r--doc/topics/git/git_log.md6
-rw-r--r--doc/topics/git/git_rebase.md19
-rw-r--r--doc/topics/git/lfs/index.md44
-rw-r--r--doc/topics/git/lfs/migrate_from_git_annex_to_git_lfs.md1
-rw-r--r--doc/topics/git/lfs/migrate_to_git_lfs.md6
-rw-r--r--doc/topics/git/merge_conflicts.md6
-rw-r--r--doc/topics/git/merge_requests.md1
-rw-r--r--doc/topics/git/numerous_undo_possibilities_in_git/img/rebase_reset.pngbin21836 -> 33399 bytes
-rw-r--r--doc/topics/git/numerous_undo_possibilities_in_git/img/revert.pngbin13243 -> 21473 bytes
-rw-r--r--doc/topics/git/numerous_undo_possibilities_in_git/index.md218
-rw-r--r--doc/topics/git/rollback_commits.md6
-rw-r--r--doc/topics/git/stash.md6
-rw-r--r--doc/topics/git/subtree.md6
-rw-r--r--doc/topics/git/tags.md2
-rw-r--r--doc/topics/git/unstage.md6
-rw-r--r--doc/topics/git/useful_git_commands.md7
22 files changed, 175 insertions, 197 deletions
diff --git a/doc/topics/git/bisect.md b/doc/topics/git/bisect.md
index 8af77031c93..e587a51ba17 100644
--- a/doc/topics/git/bisect.md
+++ b/doc/topics/git/bisect.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Bisect
+# Bisect **(FREE)**
- Find a commit that introduced a bug
- Works through a process of elimination
diff --git a/doc/topics/git/cherry_picking.md b/doc/topics/git/cherry_picking.md
index 5a0867371bb..4a875e25e1b 100644
--- a/doc/topics/git/cherry_picking.md
+++ b/doc/topics/git/cherry_picking.md
@@ -5,7 +5,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
comments: false
---
-# Cherry Pick
+# Cherry pick **(FREE)**
Given an existing commit on one branch, apply the change to another branch.
diff --git a/doc/topics/git/feature_branch_development.md b/doc/topics/git/feature_branch_development.md
index 8d18441aadd..ae1485741a5 100644
--- a/doc/topics/git/feature_branch_development.md
+++ b/doc/topics/git/feature_branch_development.md
@@ -9,7 +9,7 @@ type: how-tos
GitLab values encourage the use of [Minimal Viable Change (MVC)](https://about.gitlab.com/handbook/values/#minimal-viable-change-mvc).
However, viable changes are not always small. In such cases, it can help to set up a dedicated feature branch.
-People can contribute MRs to that feature branch, without affecting the functionality of the default (usually `master`) branch.
+People can contribute MRs to that feature branch, without affecting the functionality of the [default branch](../../user/project/repository/branches/default.md).
Once work on the development branch is complete, then the feature branch can be finally merged into the default branch.
@@ -19,14 +19,14 @@ GitLab frequently implements this process whenever there is an MVC that requires
This section describes the use case with GitLab [release posts](https://about.gitlab.com/handbook/marketing/blog/release-posts/).
Dozens of GitLab team members contribute to each monthly release post.
-In such cases, it may be more efficient to submit an MR on the release post feature branch instead of master.
+In such cases, it may be more efficient to submit an MR on the release post feature branch instead of the [default branch](../../user/project/repository/branches/default.md).
In this case, the feature branch would be `release-X-Y`. Assuming the `release-X-Y` branch already exists, you can set up an MR against that branch, with the following steps:
-1. Navigate to the main (master) branch:
+1. Navigate to the [default branch](../../user/project/repository/branches/default.md) (here, `main`):
```shell
- git checkout master
+ git checkout main
```
1. Make sure you have the latest version of your repository:
@@ -101,8 +101,8 @@ we have selected `test-branch` as the source, and `release-13-0` as the target.
Request to merge test-branch into release-13-0
```
- That confirms you've set up the MR to merge into the specified branch, not master.
+ That confirms you've set up the MR to merge into the specified branch, not the [default branch](../../user/project/repository/branches/default.md).
1. Proceed with the change as you would with any other MR.
1. When your MR is approved, and an appropriate user merges that MR, you can rest assured that your work is incorporated directly into the feature branch.
-When the feature branch is ready, it can then be merged into master.
+When the feature branch is ready, it can then be merged into the [default branch](../../user/project/repository/branches/default.md).
diff --git a/doc/topics/git/feature_branching.md b/doc/topics/git/feature_branching.md
index f6233bddb18..f0ded5511ee 100644
--- a/doc/topics/git/feature_branching.md
+++ b/doc/topics/git/feature_branching.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Feature branching
+# Feature branching **(FREE)**
- Efficient parallel workflow for teams
- Develop each feature in a branch
diff --git a/doc/topics/git/getting_started.md b/doc/topics/git/getting_started.md
index 2c3d5fe15de..7e04eae622f 100644
--- a/doc/topics/git/getting_started.md
+++ b/doc/topics/git/getting_started.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Getting Started
+# Getting started **(FREE)**
## Instantiating Repositories
diff --git a/doc/topics/git/git_add.md b/doc/topics/git/git_add.md
index d136b9151bc..e15a1e9a60d 100644
--- a/doc/topics/git/git_add.md
+++ b/doc/topics/git/git_add.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Git Add
+# Git Add **(FREE)**
Adds content to the index or staging area.
diff --git a/doc/topics/git/git_log.md b/doc/topics/git/git_log.md
index ae4ae69ce76..3988d7f7ac9 100644
--- a/doc/topics/git/git_log.md
+++ b/doc/topics/git/git_log.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Git Log
+# Git Log **(FREE)**
Git log lists commit history. It allows searching and filtering.
diff --git a/doc/topics/git/git_rebase.md b/doc/topics/git/git_rebase.md
index 78303d24a20..8844d362c10 100644
--- a/doc/topics/git/git_rebase.md
+++ b/doc/topics/git/git_rebase.md
@@ -32,7 +32,7 @@ consider pulling it instead (`git pull origin master`). It has a similar
effect without compromising the work of your contributors.
It's safer to back up your branch before rebasing to make sure you don't lose
-any changes. For example, consider a [feature branch](../../gitlab-basics/start-using-git.md#branching)
+any changes. For example, consider a [feature branch](../../gitlab-basics/start-using-git.md#branches)
called `my-feature-branch`:
1. Open your feature branch in the terminal:
@@ -80,12 +80,13 @@ ensure that the changes you're adding to the codebase do not break any
existing changes added to the target branch _after_ you created your feature
branch.
-For example, to update your branch `my-feature-branch` with `master`:
+For example, to update your branch `my-feature-branch` with your
+[default branch](../../user/project/repository/branches/default.md) (here, using `main`):
-1. Fetch the latest changes from `master`:
+1. Fetch the latest changes from `main`:
```shell
- git fetch origin master
+ git fetch origin main
```
1. Checkout your feature branch:
@@ -94,24 +95,24 @@ For example, to update your branch `my-feature-branch` with `master`:
git checkout my-feature-branch
```
-1. Rebase it against `master`:
+1. Rebase it against `main`:
```shell
- git rebase origin/master
+ git rebase origin/main
```
1. [Force-push](#force-push) to your branch.
When you rebase:
-1. Git imports all the commits submitted to `master` _after_ the
+1. Git imports all the commits submitted to `main` _after_ the
moment you created your feature branch until the present moment.
1. Git puts the commits you have in your feature branch on top of all
- the commits imported from `master`:
+ the commits imported from `main`:
![Git rebase illustration](img/git_rebase_v13_5.png)
-You can replace `master` with any other branch you want to rebase against, for
+You can replace `main` with any other branch you want to rebase against, for
example, `release-10-3`. You can also replace `origin` with other remote
repositories, for example, `upstream`. To check what remotes you have linked to your local
repository, you can run `git remote -v`.
diff --git a/doc/topics/git/lfs/index.md b/doc/topics/git/lfs/index.md
index 0851d3f6b50..dfb175cbb82 100644
--- a/doc/topics/git/lfs/index.md
+++ b/doc/topics/git/lfs/index.md
@@ -114,11 +114,9 @@ See the documentation on [File Locking](../../../user/project/file_lock.md).
## LFS objects in project archives
> - Support for including Git LFS blobs inside [project source downloads](../../../user/project/repository/index.md) was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/15079) in GitLab 13.5.
-> - [Deployed behind a feature flag](../../../user/feature_flags.md), disabled by default.
> - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/268409) in GitLab 13.6.
> - Enabled on GitLab.com.
> - Recommended for production use.
-> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-lfs-objects-in-project-archives).
WARNING:
This feature might not be available to you. Check the **version history** note above for details.
@@ -134,32 +132,40 @@ oid sha256:3ea5dd307f195f449f0e08234183b82e92c3d5f4cff11c2a6bb014f9e0de12aa
size 177735
```
-Starting with GitLab 13.5, these pointers are converted to the uploaded
-LFS object if the `include_lfs_blobs_in_archive` feature flag is
-enabled.
+In GitLab version 13.5 and later, these pointers are converted to the uploaded
+LFS object.
Technical details about how this works can be found in the [development documentation for LFS](../../../development/lfs.md#including-lfs-blobs-in-project-archives).
-### Enable or disable LFS objects in project archives
+## Troubleshooting
-_LFS objects in project archives_ is under development but ready for production use.
-It is deployed behind a feature flag that is **enabled by default**.
-[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md)
-can opt to disable it.
+### Encountered `n` file(s) that should have been pointers, but weren't
-To enable it:
+This error indicates the file (or files) are expected to be tracked by LFS, but for
+some reason the repository is not tracking them as LFS. This issue can be one
+potential reason for this error:
+[Files not tracked with LFS when uploaded through the web interface](https://gitlab.com/gitlab-org/gitlab/-/issues/326342#note_586820485)
-```ruby
-Feature.enable(:include_lfs_blobs_in_archive)
-```
+To resolve the problem, migrate the affected file (or files) and push back to the repository:
-To disable it:
+1. Migrate the file to LFS:
-```ruby
-Feature.disable(:include_lfs_blobs_in_archive)
-```
+ ```shell
+ git lfs migrate import --yes --no-rewrite "<your-file>"
+ ```
-## Troubleshooting
+1. Push back to your repository:
+
+ ```shell
+ git push
+ ```
+
+1. (Optional) Clean up your `.git` folder:
+
+ ```shell
+ git reflog expire --expire-unreachable=now --all
+ git gc --prune=now
+ ```
### error: Repository or object not found
diff --git a/doc/topics/git/lfs/migrate_from_git_annex_to_git_lfs.md b/doc/topics/git/lfs/migrate_from_git_annex_to_git_lfs.md
index 741b2a78b85..d7fb8a37b9c 100644
--- a/doc/topics/git/lfs/migrate_from_git_annex_to_git_lfs.md
+++ b/doc/topics/git/lfs/migrate_from_git_annex_to_git_lfs.md
@@ -1,5 +1,6 @@
---
redirect_to: 'index.md'
+remove_date: '2021-07-22'
---
This document was moved to [another location](index.md).
diff --git a/doc/topics/git/lfs/migrate_to_git_lfs.md b/doc/topics/git/lfs/migrate_to_git_lfs.md
index 3f8e0575add..d1231257f38 100644
--- a/doc/topics/git/lfs/migrate_to_git_lfs.md
+++ b/doc/topics/git/lfs/migrate_to_git_lfs.md
@@ -41,7 +41,7 @@ Before beginning, make sure:
To follow this tutorial, you need:
-- Maintainer permissions to the existing Git repository
+- The [Maintainer role](../../../user/permissions.md) for the existing Git repository
you'd like to migrate to LFS with access through the command line.
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
and [Java Runtime Environment](https://www.java.com/en/download/manual.jsp)
@@ -137,8 +137,8 @@ Consider an example upstream project, `git@gitlab.com:gitlab-tests/test-git-lfs-
# Change into the upstream repo directory:
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
+ # You may need to reset your local copy with upstream's `main` after force-pushing from the mirror:
+ git reset --hard origin/main
# Track the files with LFS:
git lfs track "*.gif" "*.png" "*.jpg" "*.psd" "*.mp4" "img/"
diff --git a/doc/topics/git/merge_conflicts.md b/doc/topics/git/merge_conflicts.md
index 66771559298..bf69190030c 100644
--- a/doc/topics/git/merge_conflicts.md
+++ b/doc/topics/git/merge_conflicts.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Merge conflicts
+# Merge conflicts **(FREE)**
- Happen often
- Learning to fix conflicts is hard
diff --git a/doc/topics/git/merge_requests.md b/doc/topics/git/merge_requests.md
index 751bf8195d0..d889bc8ffe5 100644
--- a/doc/topics/git/merge_requests.md
+++ b/doc/topics/git/merge_requests.md
@@ -1,5 +1,6 @@
---
redirect_to: '../../user/project/merge_requests/index.md'
+remove_date: '2021-08-13'
---
This document was moved to [another location](../../user/project/merge_requests/index.md).
diff --git a/doc/topics/git/numerous_undo_possibilities_in_git/img/rebase_reset.png b/doc/topics/git/numerous_undo_possibilities_in_git/img/rebase_reset.png
index 6506de209f4..c1a67e0b566 100644
--- a/doc/topics/git/numerous_undo_possibilities_in_git/img/rebase_reset.png
+++ b/doc/topics/git/numerous_undo_possibilities_in_git/img/rebase_reset.png
Binary files differ
diff --git a/doc/topics/git/numerous_undo_possibilities_in_git/img/revert.png b/doc/topics/git/numerous_undo_possibilities_in_git/img/revert.png
index 040f8118d72..0732a73278b 100644
--- a/doc/topics/git/numerous_undo_possibilities_in_git/img/revert.png
+++ b/doc/topics/git/numerous_undo_possibilities_in_git/img/revert.png
Binary files differ
diff --git a/doc/topics/git/numerous_undo_possibilities_in_git/index.md b/doc/topics/git/numerous_undo_possibilities_in_git/index.md
index b151ddfff71..6de62897041 100644
--- a/doc/topics/git/numerous_undo_possibilities_in_git/index.md
+++ b/doc/topics/git/numerous_undo_possibilities_in_git/index.md
@@ -36,7 +36,7 @@ You can undo changes at any point in this workflow:
- [When you're working locally](#undo-local-changes) and haven't yet pushed to a remote repository.
- When you have already pushed to a remote repository and you want to:
- [Keep the history intact](#undo-remote-changes-without-changing-history) (preferred).
- - [Change the history](#undo-remote-changes-with-modifying-history) (requires
+ - [Change the history](#undo-remote-changes-while-changing-history) (requires
coordination with team and force pushes).
## Undo local changes
@@ -139,6 +139,12 @@ If you want to change to another branch, you can use [`git stash`](https://www.g
1. Commit, push, and test.
1. Return to the branch where you want to resume your changes.
1. Use `git stash list` to list all previously stashed commits.
+
+ ```shell
+ stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
+ stash@{1}: On master: 9cc0589... Add git-stash
+ ```
+
1. Run a version of `git stash`:
- Use `git stash pop` to redo previously stashed changes and remove them from stashed list.
@@ -146,7 +152,7 @@ If you want to change to another branch, you can use [`git stash`](https://www.g
## Undo committed local changes
-When you commit to your local repository (`git commit`), the version control system records
+When you commit to your local repository (`git commit`), Git records
your changes. Because you did not push to a remote repository yet, your changes are
not public (or shared with other developers). At this point, you can undo your changes.
@@ -212,64 +218,53 @@ which clashes with what other developers have locally.
### Undo staged local changes with history modification
-You can rewrite history in Git, but you should avoid it, because it can cause problems
-when multiple developers are contributing to the same codebase.
-
-There is one command for history modification and that is `git rebase`. Command
-provides interactive mode (`-i` flag) which enables you to:
+The following tasks rewrite Git history.
-- **reword** commit messages (there is also `git commit --amend` for editing
- last commit message).
-- **edit** the commit content (changes introduced by commit) and message.
-- **squash** multiple commits into a single one, and have a custom or aggregated
- commit message.
-- **drop** commits - delete them.
-- and few more options.
+#### Delete a specific commit
-Let us check few examples. Again there are commits `A-B-C-D` where you want to
-delete commit `B`.
+You can delete a specific commit. For example, if you have
+commits `A-B-C-D` and you want to delete commit `B`.
-- Rebase the range from current commit D to A:
+1. Rebase the range from current commit `D` to `B`:
- ```shell
- git rebase -i A
- ```
+ ```shell
+ git rebase -i A
+ ```
-- Command opens your favorite editor where you write `drop` in front of commit
- `B`, but you leave default `pick` with all other commits. Save and exit the
- editor to perform a rebase. Remember: if you want to cancel delete whole
- file content before saving and exiting the editor
+ A list of commits is displayed in your editor.
-In case you want to modify something introduced in commit `B`.
+1. In front of commit `B`, replace `pick` with `drop`.
+1. Leave the default, `pick`, for all other commits.
+1. Save and exit the editor.
-- Rebase the range from current commit D to A:
+#### Modify a specific commit
- ```shell
- git rebase -i A
- ```
+You can modify a specific commit. For example, if you have
+commits `A-B-C-D` and you want to modify something introduced in commit `B`.
-- Command opens your favorite text editor where you write `edit` in front of commit
- `B`, but leave default `pick` with all other commits. Save and exit the editor to
- perform a rebase.
+1. Rebase the range from current commit `D` to `B`:
-- Now do your edits and commit changes:
+ ```shell
+ git rebase -i A
+ ```
- ```shell
- git commit -a
- ```
+ A list of commits is displayed in your editor.
+
+1. In front of commit `B`, replace `pick` with `edit`.
+1. Leave the default, `pick`, for all other commits.
+1. Save and exit the editor.
+1. Open the file in your editor, make your edits, and commit the changes:
-You can find some more examples in the section explaining
-[how to modify history](#how-modifying-history-is-done).
+ ```shell
+ git commit -a
+ ```
### Redoing the undo
-Sometimes you realize that the changes you undid were useful and you want them
-back. Well because of first paragraph you are in luck. Command `git reflog`
-enables you to *recall* detached local commits by referencing or applying them
-via commit ID. Although, do not expect to see really old commits in reflog, because
-Git regularly [cleans the commits which are *unreachable* by branches or tags](https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery).
+You can recall previous local commits. However, not all previous commits are available, because
+Git regularly [cleans the commits that are unreachable by branches or tags](https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery).
-To view repository history and to track older commits you can use below command:
+To view repository history and track prior commits, run `git reflog show`. For example:
```shell
$ git reflog show
@@ -287,89 +282,64 @@ eb37e74 HEAD@{6}: rebase -i (pick): Commit C
6e43d59 HEAD@{16}: commit: Commit B
```
-Output of command shows repository history. In first column there is commit ID,
-in following column, number next to `HEAD` indicates how many commits ago something
-was made, after that indicator of action that was made (commit, rebase, merge, ...)
-and then on end description of that action.
+This output shows the repository history, including:
-## Undo remote changes without changing history
+- The commit SHA.
+- How many `HEAD`-changing actions ago the commit was made (`HEAD@{12}` was 12 `HEAD`-changing actions ago).
+- The action that was taken, for example: commit, rebase, merge.
+- A description of the action that changed `HEAD`.
-This topic is roughly same as modifying committed local changes without modifying
-history. **It should be the preferred way of undoing changes on any remote repository
-or public branch.** Keep in mind that branching is the best solution when you want
-to retain the history of faulty development, yet start anew from certain point.
+## Undo remote changes without changing history
-Branching
-enables you to include the existing changes in new development (by merging) and
-it also provides a clear timeline and development structure.
+To undo changes in the remote repository, you can create a new commit with the changes you
+want to undo. You should follow this process, which preserves the history and
+provides a clear timeline and development structure. However, you
+only need this procedure if your work was merged into a branch that
+other developers use as the base for their work.
![Use revert to keep branch flowing](img/revert.png)
-If you want to revert changes introduced in certain `commit-id`, you can
-revert that `commit-id` (swap additions and deletions) in newly created commit:
-You can do this with
+To revert changes introduced in a specific commit `B`:
```shell
-git revert commit-id
+git revert B
```
-or creating a new branch:
-
-```shell
-git checkout commit-id
-git checkout -b new-path-of-feature
-```
+## Undo remote changes while changing history
-## Undo remote changes with modifying history
+You can undo remote changes and change history.
-This is useful when you want to *hide* certain things - like secret keys,
-passwords, and SSH keys. It is and should not be used to hide mistakes, as
-it makes it harder to debug in case there are some other bugs. The main
-reason for this is that you loose the real development progress. Keep in
-mind that, even with modified history, commits are just detached and can still be
-accessed through commit ID - at least until all repositories perform
-the automated cleanup of detached commits.
+Even with an updated history, old commits can still be
+accessed by commit SHA. This is the case at least until all the automated cleanup
+of detached commits is performed, or a cleanup is run manually. Even the cleanup might not remove old commits if there are still refs pointing to them.
![Modifying history causes problems on remote branch](img/rebase_reset.png)
-### Where modifying history is generally acceptable
+### When changing history is acceptable
-Modified history breaks the development chain of other developers, as changed
-history does not have matching commit IDs. For that reason it should not be
-used on any public branch or on branch that might be used by other developers.
-When contributing to big open source repositories (for example, [GitLab](https://gitlab.com/gitlab-org/gitlab/blob/master/CONTRIBUTING.md#contribution-acceptance-criteria)
-itself), it is acceptable to squash commits into a single one, to present a
-nicer history of your contribution.
+You should not change the history when you're working in a public branch
+or a branch that might be used by other developers.
-Keep in mind that this also removes the comments attached to certain commits
-in merge requests, so if you need to retain traceability in GitLab, then
-modifying history is not acceptable.
+When you contribute to large open source repositories, like [GitLab](https://gitlab.com/gitlab-org/gitlab),
+you can squash your commits into a single one.
-A feature branch of a merge request is a public branch and might be used by
-other developers, but project process and rules might allow or require
-you to use `git rebase` (command that changes history) to reduce number of
-displayed commits on target branch after reviews are done (for example
-GitLab). There is a `git merge --squash` command which does exactly that
-(squashes commits on feature-branch to a single commit on target branch
-at merge).
+To squash commits on a feature branch to a single commit on a target branch
+at merge, use `git merge --squash`.
NOTE:
-Never modify the commit history of `master` or shared branch.
+Never modify the commit history of your [default branch](../../../user/project/repository/branches/default.md) or shared branch.
-### How modifying history is done
+### How to change history
-After you know what you want to modify (how far in history or how which range of
-old commits), use `git rebase -i commit-id`. This command displays all the commits from
-current version to chosen commit ID and allow modification, squashing, deletion
-of that commits.
+A feature branch of a merge request is a public branch and might be used by
+other developers. However, the project rules might require
+you to use `git rebase` to reduce the number of
+displayed commits on target branch after reviews are done.
-```shell
-$ git rebase -i commit1-id..commit3-id
-pick <commit1-id> <commit1-commit-message>
-pick <commit2-id> <commit2-commit-message>
-pick <commit3-id> <commit3-commit-message>
+You can modify history by using `git rebase -i`. Use this command to modify, squash,
+and delete commits.
-# Rebase commit1-id..commit3-id onto <commit4-id> (3 command(s))
+```shell
#
# Commands:
# p, pick = use commit
@@ -382,50 +352,48 @@ pick <commit3-id> <commit3-commit-message>
#
# These lines can be re-ordered; they are executed from top to bottom.
#
-# If you remove a line here THAT COMMIT WILL BE LOST.
+# If you remove a line THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
-# Note that empty commits are commented out
+# Empty commits are commented out
```
NOTE:
-The comment from the output clearly states that, if
-you decide to abort, don't just close your editor (as that
-modifies history), but remove all uncommented lines and save.
+If you decide to stop a rebase, do not close your editor.
+Instead, remove all uncommented lines and save.
-Use `git rebase` carefully on
-shared and remote branches, but rest assured: nothing is broken until
-you push back to the remote repository (so you can freely explore the
-different outcomes locally).
+Use `git rebase` carefully on shared and remote branches.
+Experiment locally before you push to the remote repository.
```shell
# Modify history from commit-id to HEAD (current commit)
git rebase -i commit-id
```
-### Deleting sensitive information from commits
+### Delete sensitive information from commits
+
+You can use Git to delete sensitive information from your past commits. However,
+history is modified in the process.
+
+To rewrite history with
+[certain filters](https://git-scm.com/docs/git-filter-branch#_options),
+run `git filter-branch`.
-Git also enables you to delete sensitive information from your past commits and
-it does modify history in the progress. That is why we have included it in this
-section and not as a standalone topic. To do so, you should run the
-`git filter-branch`, which enables you to rewrite history with
-[certain filters](https://git-scm.com/docs/git-filter-branch#_options).
-This command uses rebase to modify history and if you want to remove certain
-file from history altogether use:
+To remove a file from the history altogether use:
```shell
git filter-branch --tree-filter 'rm filename' HEAD
```
-Because `git filter-branch` command might be slow on big repositories, there are
-tools that can use some of Git specifics to enable faster execution of common
-tasks (which is exactly what removing sensitive information file is about).
+The `git filter-branch` command might be slow on large repositories.
+Tools are available to execute Git commands more quickly.
An alternative is the open source community-maintained tool [BFG](https://rtyley.github.io/bfg-repo-cleaner/).
-Keep in mind that these tools are faster because they do not provide the same
+These tools are faster because they do not provide the same
feature set as `git filter-branch` does, but focus on specific use cases.
-Refer [Reduce repository size](../../../user/project/repository/reducing_the_repo_size_using_git.md) page to know more about purging files from repository history & GitLab storage.
+Refer to [Reduce repository size](../../../user/project/repository/reducing_the_repo_size_using_git.md) to
+learn more about purging files from repository history and GitLab storage.
<!-- ## Troubleshooting
diff --git a/doc/topics/git/rollback_commits.md b/doc/topics/git/rollback_commits.md
index 34c2d9687bb..478dce179d2 100644
--- a/doc/topics/git/rollback_commits.md
+++ b/doc/topics/git/rollback_commits.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Rollback Commits
+# Rollback commits **(FREE)**
## Undo Commits
diff --git a/doc/topics/git/stash.md b/doc/topics/git/stash.md
index 051103e5f4b..d321795e034 100644
--- a/doc/topics/git/stash.md
+++ b/doc/topics/git/stash.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Git Stash
+# Git Stash **(FREE)**
We use `git stash` to store our changes when they are not ready to be committed
and we need to change to a different branch.
diff --git a/doc/topics/git/subtree.md b/doc/topics/git/subtree.md
index 54461915a05..0bf89668405 100644
--- a/doc/topics/git/subtree.md
+++ b/doc/topics/git/subtree.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Subtree
+# Subtree **(FREE)**
- Used when there are nested repositories.
- Not recommended when the amount of dependencies is too large.
diff --git a/doc/topics/git/tags.md b/doc/topics/git/tags.md
index 70580ecf778..6e0622273bb 100644
--- a/doc/topics/git/tags.md
+++ b/doc/topics/git/tags.md
@@ -4,7 +4,7 @@ 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/#assignments
---
-# Tags
+# Tags **(FREE)**
Tags are useful for marking certain deployments and releases for later
reference. Git supports two types of tags:
diff --git a/doc/topics/git/unstage.md b/doc/topics/git/unstage.md
index 30d26854135..b5f7c01de24 100644
--- a/doc/topics/git/unstage.md
+++ b/doc/topics/git/unstage.md
@@ -1,11 +1,11 @@
---
-stage: none
-group: unassigned
+stage: Create
+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/#assignments
comments: false
---
-# Unstage
+# Unstage **(FREE)**
- To remove files from stage use reset HEAD where HEAD is the last commit of the current branch. This unstages the file but maintain the modifications.
diff --git a/doc/topics/git/useful_git_commands.md b/doc/topics/git/useful_git_commands.md
index 38b44d97583..61f170d934a 100644
--- a/doc/topics/git/useful_git_commands.md
+++ b/doc/topics/git/useful_git_commands.md
@@ -180,12 +180,13 @@ Git includes a complete set of [traces for debugging Git commands](https://git-s
## Rebasing
-### Rebase your branch onto master
+### Rebase your branch onto the default
-The `-i` flag stands for 'interactive':
+The `-i` flag stands for 'interactive'. Replace `<default-branch>` with the name
+of your [default branch](../../user/project/repository/branches/default.md):
```shell
-git rebase -i master
+git rebase -i <default-branch>
```
### Continue the rebase if paused