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/useful_git_commands.md')
-rw-r--r--doc/topics/git/useful_git_commands.md50
1 files changed, 25 insertions, 25 deletions
diff --git a/doc/topics/git/useful_git_commands.md b/doc/topics/git/useful_git_commands.md
index 68b4c772b8b..2cec0cd04f7 100644
--- a/doc/topics/git/useful_git_commands.md
+++ b/doc/topics/git/useful_git_commands.md
@@ -11,7 +11,7 @@ need to use often, but they can can come in handy when needed.
### Add another URL to a remote, so both remotes get updated on each push
-```sh
+```shell
git remote set-url --add <remote_name> <remote_url>
```
@@ -19,7 +19,7 @@ git remote set-url --add <remote_name> <remote_url>
### Remove last commit and leave the changes in unstaged
-```sh
+```shell
git reset --soft HEAD^
```
@@ -27,13 +27,13 @@ git reset --soft HEAD^
To unstage 3 commits, for example, run:
-```sh
+```shell
git reset HEAD^3
```
### Unstage changes to a certain file from HEAD
-```sh
+```shell
git reset <filename>
```
@@ -46,19 +46,19 @@ There are two options to revert changes to a file:
### Undo a previous commit by creating a new replacement commit
-```sh
+```shell
git revert <commit-sha>
```
### Create a new message for last commit
-```sh
+```shell
git commit --amend
```
### Add a file to the last commit
-```sh
+```shell
git add <filename>
git commit --amend
```
@@ -70,31 +70,31 @@ message.
### Stash changes
-```sh
+```shell
git stash save
```
The default behavior of `stash` is to save, so you can also use just:
-```sh
+```shell
git stash
```
### Unstash your changes
-```sh
+```shell
git stash apply
```
### Discard your stashed changes
-```sh
+```shell
git stash drop
```
### Apply and drop your stashed changes
-```sh
+```shell
git stash pop
```
@@ -102,7 +102,7 @@ git stash pop
### Use reflog to show the log of reference changes to HEAD
-```sh
+```shell
git reflog
```
@@ -110,7 +110,7 @@ git reflog
The basic command to check the Git history of a file:
-```sh
+```shell
git log <file>
```
@@ -123,25 +123,25 @@ Use '--' to separate paths from revisions, like this:
Use this to check the Git history of the file:
-```sh
+```shell
git log -- <file>
```
### Find the tags that contain a particular SHA
-```sh
+```shell
git tag --contains <sha>
```
### Check the content of each change to a file
-```sh
+```shell
gitk <file>
```
### Check the content of each change to a file, follows it past file renames
-```sh
+```shell
gitk --follow <file>
```
@@ -149,7 +149,7 @@ gitk --follow <file>
### Use a custom SSH key for a Git command
-```sh
+```shell
GIT_SSH_COMMAND="ssh -i ~/.ssh/gitlabadmin" git <command>
```
@@ -157,13 +157,13 @@ GIT_SSH_COMMAND="ssh -i ~/.ssh/gitlabadmin" git <command>
With SSH:
-```sh
+```shell
GIT_SSH_COMMAND="ssh -vvv" git clone <git@url>
```
With HTTPS:
-```sh
+```shell
GIT_TRACE_PACKET=1 GIT_TRACE=2 GIT_CURL_VERBOSE=1 git clone <url>
```
@@ -181,13 +181,13 @@ Git includes a complete set of [traces for debugging Git commands](https://git-s
The -i flag stands for 'interactive':
-```sh
+```shell
git rebase -i master
```
### Continue the rebase if paused
-```sh
+```shell
git rebase --continue
```
@@ -195,13 +195,13 @@ git rebase --continue
To _reuse_ recorded solutions to the same problems when repeated:
-```sh
+```shell
git rerere
```
To enable `rerere` functionality:
-```sh
+```shell
git config --global rerere.enabled true
```