chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
286a93fb-2bde-4346-9022-1d1adcb5ca88 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/branches-containing-commit.md | unknown | 8edf695a-6064-494c-bfbe-15d72297e29e | 2 | SemanticChunker@1.0.0 | 46f6875cb8a546f41206e41078db66c03ae7ce608d2ce7e8f1e90bd122a6c48d | [Branches that contain a commit > Branches that don't contain a commit]
## Branches that don't contain a commit
Similarly, you can look for **branches that don't contain a specific commit** by using the `--no-contains` flag.
```shell
# Syntax: git branch --no-contains <commit>
git branch --no-contains 3050fc0
# mas... | unknown | unknown | [Branches that contain a commit > Branches that don't contain a commit]
## Branches that don't contain a commit
Similarly, you can look for **branches that don't contain a specific commit** by using the `--no-contains` flag.
```shell
# Syntax: git branch --no-contains <commit>
git branch --no-contains 3050fc0
# mas... | [Branches that contain a commit > Branches that don't contain a commit]
## Branches that don't contain a commit
Similarly, you can look for **branches that don't contain a specific commit** by using the `--no-contains` flag.
```shell
# Syntax: git branch --no-contains <commit>
git branch --no-contains 3050fc0
# mas... | code_snippets | ||
36a4ca0f-0b9f-49aa-84a3-e700d5d78826 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/branches-containing-commit.md | unknown | 8edf695a-6064-494c-bfbe-15d72297e29e | 1 | SemanticChunker@1.0.0 | 4b09f1254d83be48edf3bb7aaa7e5dbcf1223ffc72beaa75e985eb32102210ba | [Branches that contain a commit]
## Branches that contain a commit
As usual, Git has a simple solution to this problem. Using `git branch` with the `--contains` flag will print all the **branches containing a specific commit**.
```shell
# Syntax: git branch --contains <commit>
git branch --contains 3050fc0
# develo... | unknown | unknown | [Branches that contain a commit]
## Branches that contain a commit
As usual, Git has a simple solution to this problem. Using `git branch` with the `--contains` flag will print all the **branches containing a specific commit**.
```shell
# Syntax: git branch --contains <commit>
git branch --contains 3050fc0
# develo... | [Branches that contain a commit]
## Branches that contain a commit
As usual, Git has a simple solution to this problem. Using `git branch` with the `--contains` flag will print all the **branches containing a specific commit**.
```shell
# Syntax: git branch --contains <commit>
git branch --contains 3050fc0
# develo... | code_snippets | ||
c33bdb97-6dfd-4352-874a-2c86dfeb51ef | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/cherry-pick-unreachable-github-commit.md | unknown | 600f9ef4-e46a-48ed-9eda-e18add4f2fc3 | 0 | SemanticChunker@1.0.0 | 6d8afad09ee4da4444938494a65a940e56809d3344753d660bbd29e3792beb7a | ---
title: Cherry-pick an unreachable GitHub commit
shortTitle: Cherry-pick unreachable commit
language: git
tags: [commit,branch]
cover: laptop-bronze-mug
excerpt: Have you ever needed to cherry pick a GitHub commit that does not belong to any branch on this repository? Here's an easy way to do it.
listed: true
dateMo... | unknown | unknown | ---
title: Cherry-pick an unreachable GitHub commit
shortTitle: Cherry-pick unreachable commit
language: git
tags: [commit,branch]
cover: laptop-bronze-mug
excerpt: Have you ever needed to cherry pick a GitHub commit that does not belong to any branch on this repository? Here's an easy way to do it.
listed: true
dateMo... | ---
title: Cherry-pick an unreachable GitHub commit
shortTitle: Cherry-pick unreachable commit
language: git
tags: [commit,branch]
cover: laptop-bronze-mug
excerpt: Have you ever needed to cherry pick a GitHub commit that does not belong to any branch on this repository? Here's an easy way to do it.
listed: true
dateMo... | code_snippets | ||
f7ccc6ed-a54d-4c9a-bc9f-ce71271ac8ac | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/commit-different-date.md | unknown | 9079a909-0fe7-453c-a210-ed9764d3669d | 0 | SemanticChunker@1.0.0 | 4daf35dcc7a20283af8df242eaa343be6752ef29db5d49fdfb0496c66115cb3e | ---
title: Create a commit with a different date
language: git
tags: [commit]
cover: ice
excerpt: Ever needed to create a git commit with a different date? Here's a quick and easy way to do it.
listed: true
dateModified: 2021-06-12
---
Sometimes, you might run into a situation where you need to create a commit with a ... | unknown | unknown | ---
title: Create a commit with a different date
language: git
tags: [commit]
cover: ice
excerpt: Ever needed to create a git commit with a different date? Here's a quick and easy way to do it.
listed: true
dateModified: 2021-06-12
---
Sometimes, you might run into a situation where you need to create a commit with a ... | ---
title: Create a commit with a different date
language: git
tags: [commit]
cover: ice
excerpt: Ever needed to create a git commit with a different date? Here's a quick and easy way to do it.
listed: true
dateModified: 2021-06-12
---
Sometimes, you might run into a situation where you need to create a commit with a ... | code_snippets | ||
37930003-b65c-4ee1-8888-c836bc5bd60e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/commit-template.md | unknown | 19d3e07a-c34e-44f4-880c-31ad3c264f4b | 1 | SemanticChunker@1.0.0 | 3791fdc9280a778f2b27a44f9f0c03700fe047f7c2a1192847d066a15667e4c4 | [Specification: https://www.conventionalcommits.org/en/v1.0.0/#specification]
# Specification: https://www.conventionalcommits.org/en/v1.0.0/#specification
```
```shell
git config commit.template "commit-template"
# Sets the above "commit-template" as the commit message template
``` | unknown | unknown | [Specification: https://www.conventionalcommits.org/en/v1.0.0/#specification]
# Specification: https://www.conventionalcommits.org/en/v1.0.0/#specification
```
```shell
git config commit.template "commit-template"
# Sets the above "commit-template" as the commit message template
``` | [Specification: https://www.conventionalcommits.org/en/v1.0.0/#specification]
# Specification: https://www.conventionalcommits.org/en/v1.0.0/#specification
```
```shell
git config commit.template "commit-template"
# Sets the above "commit-template" as the commit message template
``` | code_snippets | ||
647ff1b1-63e4-4ccf-b359-0764fd7626b2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/commit-template.md | unknown | 19d3e07a-c34e-44f4-880c-31ad3c264f4b | 0 | SemanticChunker@1.0.0 | 6c2ad65f5ca8b7cadf92b038b710a359cf707fd09edfcf899675da4aa7814d3e | ---
title: Add a Git commit message template
shortTitle: Add commit template
language: git
tags: [repository,configuration]
cover: river-house-lights
excerpt: If you want your team to follow a common format for commit messages, you can set up a commit message template to make it easier.
listed: true
dateModified: 2024-... | unknown | unknown | ---
title: Add a Git commit message template
shortTitle: Add commit template
language: git
tags: [repository,configuration]
cover: river-house-lights
excerpt: If you want your team to follow a common format for commit messages, you can set up a commit message template to make it easier.
listed: true
dateModified: 2024-... | ---
title: Add a Git commit message template
shortTitle: Add commit template
language: git
tags: [repository,configuration]
cover: river-house-lights
excerpt: If you want your team to follow a common format for commit messages, you can set up a commit message template to make it easier.
listed: true
dateModified: 2024-... | code_snippets | ||
607fc0da-e477-4e6b-9d42-ce44e2440e02 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/clone-repo.md | unknown | f452d226-8606-422b-844b-49a41652d49e | 0 | SemanticChunker@1.0.0 | 9f82bb488417f615ac79f5ea7a08f0f05ed47fbc230befc13139d121c3137e51 | ---
title: Clone a Git repository
shortTitle: Clone repository
language: git
tags: [repository,remote]
cover: fruit-feast
excerpt: The first step to working with a Git repository is often to clone it to your local machine.
listed: true
dateModified: 2024-04-24
---
The first step to working with a Git repository is oft... | unknown | unknown | ---
title: Clone a Git repository
shortTitle: Clone repository
language: git
tags: [repository,remote]
cover: fruit-feast
excerpt: The first step to working with a Git repository is often to clone it to your local machine.
listed: true
dateModified: 2024-04-24
---
The first step to working with a Git repository is oft... | ---
title: Clone a Git repository
shortTitle: Clone repository
language: git
tags: [repository,remote]
cover: fruit-feast
excerpt: The first step to working with a Git repository is often to clone it to your local machine.
listed: true
dateModified: 2024-04-24
---
The first step to working with a Git repository is oft... | code_snippets | ||
98a46541-5106-4873-a4c7-3d3d974bf90a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/automatic-push-upstream.md | unknown | 668dba3c-3a9c-4872-97e1-8dc6c530b5da | 0 | SemanticChunker@1.0.0 | fee3fa4ecc78c645ae0b48a0889d49118c0d01c83127b41493b117ad89a2b015 | ---
title: Automate Git upstream branch creation
shortTitle: Automate upstream branch creation
language: git
tags: [configuration,repository]
cover: messy-computer
excerpt: Effortlessly create upstream branches on push by enabling a simple Git config setting.
listed: true
dateModified: 2023-05-21
---
Manually creating... | unknown | unknown | ---
title: Automate Git upstream branch creation
shortTitle: Automate upstream branch creation
language: git
tags: [configuration,repository]
cover: messy-computer
excerpt: Effortlessly create upstream branches on push by enabling a simple Git config setting.
listed: true
dateModified: 2023-05-21
---
Manually creating... | ---
title: Automate Git upstream branch creation
shortTitle: Automate upstream branch creation
language: git
tags: [configuration,repository]
cover: messy-computer
excerpt: Effortlessly create upstream branches on push by enabling a simple Git config setting.
listed: true
dateModified: 2023-05-21
---
Manually creating... | code_snippets | ||
75217bac-ce16-49d9-9407-1ced4362b85c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/autocorrect.md | unknown | a2d1dfba-bc32-486c-b416-5412dd73cb9c | 1 | SemanticChunker@1.0.0 | 4f0dffc5c964dc38bcd27f25a5b7bf9e9419f2e1acddcdc6482ebbc9530f4827 | [Enable autocorrect]
## Enable autocorrect
By setting the value to an **integer**, Git will wait for that many **tenths of a second** before executing the corrected command. For example, setting `help.autocorrect` to `1` will make Git wait for 0.1 seconds before executing the corrected command. Allowed values are bet... | unknown | unknown | [Enable autocorrect]
## Enable autocorrect
By setting the value to an **integer**, Git will wait for that many **tenths of a second** before executing the corrected command. For example, setting `help.autocorrect` to `1` will make Git wait for 0.1 seconds before executing the corrected command. Allowed values are bet... | [Enable autocorrect]
## Enable autocorrect
By setting the value to an **integer**, Git will wait for that many **tenths of a second** before executing the corrected command. For example, setting `help.autocorrect` to `1` will make Git wait for 0.1 seconds before executing the corrected command. Allowed values are bet... | code_snippets | ||
aa6c96f8-7a6a-4369-8fa2-b9a7329c8a72 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/autocorrect.md | unknown | a2d1dfba-bc32-486c-b416-5412dd73cb9c | 0 | SemanticChunker@1.0.0 | d8beac91eef007a23812b4e97fb4fe4fcf5732a6ede81709ac0d9ed96a423135 | ---
title: Enable autocorrect for mistyped Git commands
shortTitle: Enable Git autocorrect
language: git
tags: [configuration]
cover: purple-flower-bunch
excerpt: Mistyping commands often? Enable Git's autocorrect feature to automatically fix them.
listed: true
dateModified: 2024-03-28
---
Do you find yourself mistypi... | unknown | unknown | ---
title: Enable autocorrect for mistyped Git commands
shortTitle: Enable Git autocorrect
language: git
tags: [configuration]
cover: purple-flower-bunch
excerpt: Mistyping commands often? Enable Git's autocorrect feature to automatically fix them.
listed: true
dateModified: 2024-03-28
---
Do you find yourself mistypi... | ---
title: Enable autocorrect for mistyped Git commands
shortTitle: Enable Git autocorrect
language: git
tags: [configuration]
cover: purple-flower-bunch
excerpt: Mistyping commands often? Enable Git's autocorrect feature to automatically fix them.
listed: true
dateModified: 2024-03-28
---
Do you find yourself mistypi... | code_snippets | ||
d83953cf-5bba-49c8-8e9b-12dc0b057515 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/autocorrect.md | unknown | a2d1dfba-bc32-486c-b416-5412dd73cb9c | 2 | SemanticChunker@1.0.0 | 6251fbbd9e4bd51ecfbc243aaa5b6486dc0101a8a6adcfa99185363992bc22bb | [Enable autocorrect > Additional options]
## Additional options
Additionally, you can use some **keywords** to specify the autocorrect behavior, such as `never` to **disable** autocorrect, `immediate` to execute the corrected command **immediately**, and `prompt` to ask for **confirmation** before executing the corre... | unknown | unknown | [Enable autocorrect > Additional options]
## Additional options
Additionally, you can use some **keywords** to specify the autocorrect behavior, such as `never` to **disable** autocorrect, `immediate` to execute the corrected command **immediately**, and `prompt` to ask for **confirmation** before executing the corre... | [Enable autocorrect > Additional options]
## Additional options
Additionally, you can use some **keywords** to specify the autocorrect behavior, such as `never` to **disable** autocorrect, `immediate` to execute the corrected command **immediately**, and `prompt` to ask for **confirmation** before executing the corre... | code_snippets | ||
d2149e87-1ace-4ba4-b5a9-12fa5acab9c9 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/config-user.md | unknown | 851763cd-41d8-4734-8930-3cab86c45183 | 0 | SemanticChunker@1.0.0 | 20631b26b77385f18e0181420cdfcdc09295c979aa9351682cff927de566f6f5 | ---
title: Configure Git user information
shortTitle: Configure user
language: git
tags: [configuration,repository]
cover: pineapple-at-work
excerpt: Configure user information for Git to associate commits with a user.
listed: true
dateModified: 2024-04-04
---
Configuring Git **user information** is essential to assoc... | unknown | unknown | ---
title: Configure Git user information
shortTitle: Configure user
language: git
tags: [configuration,repository]
cover: pineapple-at-work
excerpt: Configure user information for Git to associate commits with a user.
listed: true
dateModified: 2024-04-04
---
Configuring Git **user information** is essential to assoc... | ---
title: Configure Git user information
shortTitle: Configure user
language: git
tags: [configuration,repository]
cover: pineapple-at-work
excerpt: Configure user information for Git to associate commits with a user.
listed: true
dateModified: 2024-04-04
---
Configuring Git **user information** is essential to assoc... | code_snippets | ||
0719fb17-2201-461a-b2c7-7098ce18a9ca | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/aliases.md | unknown | 59632970-9333-4833-8b68-f874673ca8dd | 2 | SemanticChunker@1.0.0 | d9ce74e9237ce0554dda3845977228d145f755e87c4da123f9135375d2498338 | [Creating aliases > Useful aliases]
## Useful aliases
Below you can find a list of aliases I've found personally useful for increasing productivity when working with Git. Feel free to use them as they are or modify them to suit your needs.
```properties title="~/.gitconfig"
[alias]
co = checkout
cob = checkout -b
... | unknown | unknown | [Creating aliases > Useful aliases]
## Useful aliases
Below you can find a list of aliases I've found personally useful for increasing productivity when working with Git. Feel free to use them as they are or modify them to suit your needs.
```properties title="~/.gitconfig"
[alias]
co = checkout
cob = checkout -b
... | [Creating aliases > Useful aliases]
## Useful aliases
Below you can find a list of aliases I've found personally useful for increasing productivity when working with Git. Feel free to use them as they are or modify them to suit your needs.
```properties title="~/.gitconfig"
[alias]
co = checkout
cob = checkout -b
... | code_snippets | ||
c11813d2-62d8-4f5c-81d6-5f61f636a029 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/aliases.md | unknown | 59632970-9333-4833-8b68-f874673ca8dd | 1 | SemanticChunker@1.0.0 | c6c1ba545473658a0f60e866389053c47f31a09dc19f1c2e103528beb4888ea6 | [Creating aliases]
## Creating aliases
Simply running `git config --global alias.<alias> <command>` will create an **alias for the specified command**. The alias can then be used in place of the command when running Git commands. If your command contains spaces, you can wrap it in quotes.
```shell
# Syntax: git conf... | unknown | unknown | [Creating aliases]
## Creating aliases
Simply running `git config --global alias.<alias> <command>` will create an **alias for the specified command**. The alias can then be used in place of the command when running Git commands. If your command contains spaces, you can wrap it in quotes.
```shell
# Syntax: git conf... | [Creating aliases]
## Creating aliases
Simply running `git config --global alias.<alias> <command>` will create an **alias for the specified command**. The alias can then be used in place of the command when running Git commands. If your command contains spaces, you can wrap it in quotes.
```shell
# Syntax: git conf... | code_snippets | ||
fd0ce6e4-1fd8-4f73-b5d6-411978627d29 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/aliases.md | unknown | 59632970-9333-4833-8b68-f874673ca8dd | 0 | SemanticChunker@1.0.0 | 369ad22ff85b66127e41b17ec6a59e425c05af573414dd3d14efa76fd1c38a3e | ---
title: Customize Git using aliases for common operations
shortTitle: Git aliases
language: git
tags: [configuration,cheatsheet]
cover: compass-1
excerpt: Increase your productivity and reduce your cognitive load by creating aliases for many common git operations.
listed: true
dateModified: 2025-12-20
---
Git allow... | unknown | unknown | ---
title: Customize Git using aliases for common operations
shortTitle: Git aliases
language: git
tags: [configuration,cheatsheet]
cover: compass-1
excerpt: Increase your productivity and reduce your cognitive load by creating aliases for many common git operations.
listed: true
dateModified: 2025-12-20
---
Git allow... | ---
title: Customize Git using aliases for common operations
shortTitle: Git aliases
language: git
tags: [configuration,cheatsheet]
cover: compass-1
excerpt: Increase your productivity and reduce your cognitive load by creating aliases for many common git operations.
listed: true
dateModified: 2025-12-20
---
Git allow... | code_snippets | ||
d4008007-800b-4b96-b3c9-387809d5790d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/disable-fast-forward.md | unknown | 8e46b68f-0ae6-4371-8d59-6dd42bd02a85 | 0 | SemanticChunker@1.0.0 | a413fa35dd950636d728733d12c44669c5dd5ec1cdd81d669e8e43dc0474834b | ---
title: How can I disable Git's fast forward merging by default?
shortTitle: Disable fast forward merging by default
language: git
tags: [configuration,repository]
cover: people-on-beach
excerpt: Git defaults to fast-forward merging when possible. But, what if you want to disable it by default? Let's see how you can... | unknown | unknown | ---
title: How can I disable Git's fast forward merging by default?
shortTitle: Disable fast forward merging by default
language: git
tags: [configuration,repository]
cover: people-on-beach
excerpt: Git defaults to fast-forward merging when possible. But, what if you want to disable it by default? Let's see how you can... | ---
title: How can I disable Git's fast forward merging by default?
shortTitle: Disable fast forward merging by default
language: git
tags: [configuration,repository]
cover: people-on-beach
excerpt: Git defaults to fast-forward merging when possible. But, what if you want to disable it by default? Let's see how you can... | code_snippets | ||
55a8028a-a6e1-47c9-83a7-93b33ad631f4 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/discard-changes.md | unknown | 5b31624b-2e60-40ee-add8-842a68149ee5 | 2 | SemanticChunker@1.0.0 | 82f9f1e6165967a8b7cf08da7f4607791d340e68a4fd1d867759edbd28dd3dec | [Discard uncommitted changes > Discard untracked changes]
## Discard untracked changes
Similarly, if you have untracked files in your working directory that you want to discard, you can use the `git clean -f -d` command. This command will **remove all untracked files and directories from your working directory**.
> ... | unknown | unknown | [Discard uncommitted changes > Discard untracked changes]
## Discard untracked changes
Similarly, if you have untracked files in your working directory that you want to discard, you can use the `git clean -f -d` command. This command will **remove all untracked files and directories from your working directory**.
> ... | [Discard uncommitted changes > Discard untracked changes]
## Discard untracked changes
Similarly, if you have untracked files in your working directory that you want to discard, you can use the `git clean -f -d` command. This command will **remove all untracked files and directories from your working directory**.
> ... | code_snippets | ||
ae212b83-d9e4-44af-9d62-fef08021a412 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/discard-changes.md | unknown | 5b31624b-2e60-40ee-add8-842a68149ee5 | 1 | SemanticChunker@1.0.0 | d152a7fe1c6c739a12e738c7d636d44a19594a7ecf7a2772340aa63b06543888 | [Discard uncommitted changes]
## Discard uncommitted changes
If you have made changes to your files but haven't committed them yet, you can discard them using the `git reset --hard HEAD` command. This command will **reset your working directory to match the latest commit on the current branch**, discarding all uncomm... | unknown | unknown | [Discard uncommitted changes]
## Discard uncommitted changes
If you have made changes to your files but haven't committed them yet, you can discard them using the `git reset --hard HEAD` command. This command will **reset your working directory to match the latest commit on the current branch**, discarding all uncomm... | [Discard uncommitted changes]
## Discard uncommitted changes
If you have made changes to your files but haven't committed them yet, you can discard them using the `git reset --hard HEAD` command. This command will **reset your working directory to match the latest commit on the current branch**, discarding all uncomm... | code_snippets | ||
e609b55b-09ae-4413-ab10-9bfc07a8cb4b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/discard-changes.md | unknown | 5b31624b-2e60-40ee-add8-842a68149ee5 | 0 | SemanticChunker@1.0.0 | e0c98e00df7a9f3881e3d483d867809a198b2a516220857b2f5d17f9760fc10b | ---
title: Discard uncommitted or untracked changes in Git
shortTitle: Discard changes
language: git
tags: [branch]
cover: cold-mountains
excerpt: Made some changes you don't want to keep? Learn how to discard uncommitted or untracked changes in Git.
listed: true
dateModified: 2024-04-12
---
Made some changes you don'... | unknown | unknown | ---
title: Discard uncommitted or untracked changes in Git
shortTitle: Discard changes
language: git
tags: [branch]
cover: cold-mountains
excerpt: Made some changes you don't want to keep? Learn how to discard uncommitted or untracked changes in Git.
listed: true
dateModified: 2024-04-12
---
Made some changes you don'... | ---
title: Discard uncommitted or untracked changes in Git
shortTitle: Discard changes
language: git
tags: [branch]
cover: cold-mountains
excerpt: Made some changes you don't want to keep? Learn how to discard uncommitted or untracked changes in Git.
listed: true
dateModified: 2024-04-12
---
Made some changes you don'... | code_snippets | ||
276d3f2b-716b-4699-896f-e8c20615a4d0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/delete-branch.md | unknown | 9dce5bfc-3c53-4044-b759-d2b572fa3d01 | 4 | SemanticChunker@1.0.0 | 529739dbddc42e7f607465e9abb2080c57e0c652adf87c26eb63c2b5253ab920 | [Delete local branch > Delete merged branches]
## Delete merged branches
You can use `git branch --merged <branch>` to **list all branches merged into the target** `<branch>` (e.g. `master`). Then, you can use the pipe operator (`|`) to **pipe the output** and `grep -v "(^\*|<branch>)"` to exclude the current and the... | unknown | unknown | [Delete local branch > Delete merged branches]
## Delete merged branches
You can use `git branch --merged <branch>` to **list all branches merged into the target** `<branch>` (e.g. `master`). Then, you can use the pipe operator (`|`) to **pipe the output** and `grep -v "(^\*|<branch>)"` to exclude the current and the... | [Delete local branch > Delete merged branches]
## Delete merged branches
You can use `git branch --merged <branch>` to **list all branches merged into the target** `<branch>` (e.g. `master`). Then, you can use the pipe operator (`|`) to **pipe the output** and `grep -v "(^\*|<branch>)"` to exclude the current and the... | code_snippets | ||
2b0f9d0b-b504-4471-bf43-c3f9136dc90e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/delete-branch.md | unknown | 9dce5bfc-3c53-4044-b759-d2b572fa3d01 | 1 | SemanticChunker@1.0.0 | bce79cf51e626f3c2e7d287f869aebafac483517945aa176989ebe677faa2a81 | [Delete local branch]
## Delete local branch
In order to **delete a local branch**, you can use the `git branch -d <branch>` command. This command deletes the specified local `<branch>`. Note that you need to **switch to a different branch** before deleting the target branch. Remember that, if the branch has a remote... | unknown | unknown | [Delete local branch]
## Delete local branch
In order to **delete a local branch**, you can use the `git branch -d <branch>` command. This command deletes the specified local `<branch>`. Note that you need to **switch to a different branch** before deleting the target branch. Remember that, if the branch has a remote... | [Delete local branch]
## Delete local branch
In order to **delete a local branch**, you can use the `git branch -d <branch>` command. This command deletes the specified local `<branch>`. Note that you need to **switch to a different branch** before deleting the target branch. Remember that, if the branch has a remote... | code_snippets | ||
5cdad03c-1ef7-4308-b68d-38b7c44e849a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/delete-branch.md | unknown | 9dce5bfc-3c53-4044-b759-d2b572fa3d01 | 2 | SemanticChunker@1.0.0 | 6758495395e28bea4b991b509d4385ffb3c9910e7597ce0ff0dc6e5bae87b3ee | [Delete local branch > Delete remote branch]
## Delete remote branch
Similar to deleting a local branch, you can **delete a remote branch** using the `git push -d <remote> <branch>` command. This command deletes the specified remote `<branch>` on the given `<remote>`.
```shell
# Usage: git push -d <remote> <branch>
... | unknown | unknown | [Delete local branch > Delete remote branch]
## Delete remote branch
Similar to deleting a local branch, you can **delete a remote branch** using the `git push -d <remote> <branch>` command. This command deletes the specified remote `<branch>` on the given `<remote>`.
```shell
# Usage: git push -d <remote> <branch>
... | [Delete local branch > Delete remote branch]
## Delete remote branch
Similar to deleting a local branch, you can **delete a remote branch** using the `git push -d <remote> <branch>` command. This command deletes the specified remote `<branch>` on the given `<remote>`.
```shell
# Usage: git push -d <remote> <branch>
... | code_snippets | ||
69ccbfb7-256f-487f-8bf0-48a87b27069e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/delete-branch.md | unknown | 9dce5bfc-3c53-4044-b759-d2b572fa3d01 | 0 | SemanticChunker@1.0.0 | 47d4abbfd53d59c6a64b2828e2834da71e85f901992d945ce72ea0b6948f5a47 | ---
title: Delete a Git branch
shortTitle: Delete branch
language: git
tags: [repository,branch]
cover: volcano-sunset
excerpt: Having trouble deleting branches in Git? Here's a guide to help you delete local, remote, detached, and merged branches.
listed: true
dateModified: 2024-04-06
---
Branches are an essential pa... | unknown | unknown | ---
title: Delete a Git branch
shortTitle: Delete branch
language: git
tags: [repository,branch]
cover: volcano-sunset
excerpt: Having trouble deleting branches in Git? Here's a guide to help you delete local, remote, detached, and merged branches.
listed: true
dateModified: 2024-04-06
---
Branches are an essential pa... | ---
title: Delete a Git branch
shortTitle: Delete branch
language: git
tags: [repository,branch]
cover: volcano-sunset
excerpt: Having trouble deleting branches in Git? Here's a guide to help you delete local, remote, detached, and merged branches.
listed: true
dateModified: 2024-04-06
---
Branches are an essential pa... | code_snippets | ||
7d35b8e9-0c91-45ed-9035-dbf233439071 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/delete-branch.md | unknown | 9dce5bfc-3c53-4044-b759-d2b572fa3d01 | 3 | SemanticChunker@1.0.0 | a3a97102e870dbb725df5e31bb1268a0c1ea0a82845d542a94f9090772a5b4d0 | [Delete local branch > Delete detached branches]
## Delete detached branches
Detached branches are branches that are **not associated with any commit**. They are often created when you check out a specific commit or tag. You can use the `git fetch --all --prune` command **garbage collect** any detached branches.
Thi... | unknown | unknown | [Delete local branch > Delete detached branches]
## Delete detached branches
Detached branches are branches that are **not associated with any commit**. They are often created when you check out a specific commit or tag. You can use the `git fetch --all --prune` command **garbage collect** any detached branches.
Thi... | [Delete local branch > Delete detached branches]
## Delete detached branches
Detached branches are branches that are **not associated with any commit**. They are often created when you check out a specific commit or tag. You can use the `git fetch --all --prune` command **garbage collect** any detached branches.
Thi... | code_snippets | ||
c824dd9d-c3b2-48b6-b587-4bd7149f2749 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/difference-between-branches.md | unknown | 7be578c8-26fa-42ac-8f99-3238a8eab569 | 0 | SemanticChunker@1.0.0 | 1b8f3e95564c27a07b447a3109cfe5e24b10a2851ebc76c344992c4d79e9ae2c | ---
title: View difference between two Git branches
shortTitle: Difference between branches
language: git
tags: [branch]
cover: two-doors
excerpt: Want to compare the changes between two branches in Git? Here's how you can do it.
listed: true
dateModified: 2024-04-23
---
Comparing **changes between different revisions... | unknown | unknown | ---
title: View difference between two Git branches
shortTitle: Difference between branches
language: git
tags: [branch]
cover: two-doors
excerpt: Want to compare the changes between two branches in Git? Here's how you can do it.
listed: true
dateModified: 2024-04-23
---
Comparing **changes between different revisions... | ---
title: View difference between two Git branches
shortTitle: Difference between branches
language: git
tags: [branch]
cover: two-doors
excerpt: Want to compare the changes between two branches in Git? Here's how you can do it.
listed: true
dateModified: 2024-04-23
---
Comparing **changes between different revisions... | code_snippets | ||
1f9c1d8a-3f99-42a1-95a2-5f5cec8cb965 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-commit.md | unknown | 12a11a92-5787-4231-8d0b-748eb6454f99 | 3 | SemanticChunker@1.0.0 | 169246fd7f802fdb7920350df1556fa3e32bd236eb516302963ba03c937d2317 | [Create a commit > Create an empty commit]
## Create an empty commit
Empty commits are sometimes useful when you want to **mark a point in history** without making any changes. You can create an empty commit using the `--allow-empty` option with the `git commit` command. Running `git commit --allow-empty -m <message>... | unknown | unknown | [Create a commit > Create an empty commit]
## Create an empty commit
Empty commits are sometimes useful when you want to **mark a point in history** without making any changes. You can create an empty commit using the `--allow-empty` option with the `git commit` command. Running `git commit --allow-empty -m <message>... | [Create a commit > Create an empty commit]
## Create an empty commit
Empty commits are sometimes useful when you want to **mark a point in history** without making any changes. You can create an empty commit using the `--allow-empty` option with the `git commit` command. Running `git commit --allow-empty -m <message>... | code_snippets | ||
7c755bfa-ee31-48c5-88cd-6fa1c0287555 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-commit.md | unknown | 12a11a92-5787-4231-8d0b-748eb6454f99 | 2 | SemanticChunker@1.0.0 | 341bd63309f83b1d4208b27c6f3eada2775a205d2f721bc514b312f78269ca8c | [Create a commit > Commit without running git hooks]
## Commit without running git hooks
If, for whatever reason, you want to skip the **pre-commit** and **commit-msg** hooks, you can use the `--no-verify` option with the `git commit` command. Running `git commit --no-verify -m <message>` will commit the staged chang... | unknown | unknown | [Create a commit > Commit without running git hooks]
## Commit without running git hooks
If, for whatever reason, you want to skip the **pre-commit** and **commit-msg** hooks, you can use the `--no-verify` option with the `git commit` command. Running `git commit --no-verify -m <message>` will commit the staged chang... | [Create a commit > Commit without running git hooks]
## Commit without running git hooks
If, for whatever reason, you want to skip the **pre-commit** and **commit-msg** hooks, you can use the `--no-verify` option with the `git commit` command. Running `git commit --no-verify -m <message>` will commit the staged chang... | code_snippets | ||
a7562d81-93a4-4c70-8d1c-e1b4f3ca5207 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-commit.md | unknown | 12a11a92-5787-4231-8d0b-748eb6454f99 | 1 | SemanticChunker@1.0.0 | 674b7daff4668e90003a8c06e49c0b35b5d988f1043736107844d6ba02bc8be7 | [Create a commit]
## Create a commit
Using `git commit -m <message>`, you can create a new commit with the **staged changes** and the specified `<message>`. If you omit the `-m` option, Git will open the default text editor to enter the commit message.
> [!TIP]
>
> If you want to learn how to [configure Git's defaul... | unknown | unknown | [Create a commit]
## Create a commit
Using `git commit -m <message>`, you can create a new commit with the **staged changes** and the specified `<message>`. If you omit the `-m` option, Git will open the default text editor to enter the commit message.
> [!TIP]
>
> If you want to learn how to [configure Git's defaul... | [Create a commit]
## Create a commit
Using `git commit -m <message>`, you can create a new commit with the **staged changes** and the specified `<message>`. If you omit the `-m` option, Git will open the default text editor to enter the commit message.
> [!TIP]
>
> If you want to learn how to [configure Git's defaul... | code_snippets | ||
c461827c-edae-4cb2-a3df-7e2a3ac5c71a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-commit.md | unknown | 12a11a92-5787-4231-8d0b-748eb6454f99 | 0 | SemanticChunker@1.0.0 | 2bb9b6e223697a9a9b6e3212aa69f7dddf7f2728d84f33f5841a286e31efbffd | ---
title: Create a Git commit
shortTitle: Create commit
language: git
tags: [commit]
cover: cave-explorer
excerpt: Learn how to create a new commit in Git, along with tricks to skip Git hooks and create empty commits.
listed: true
dateModified: 2024-04-20
---
The building block of version control in Git is the **comm... | unknown | unknown | ---
title: Create a Git commit
shortTitle: Create commit
language: git
tags: [commit]
cover: cave-explorer
excerpt: Learn how to create a new commit in Git, along with tricks to skip Git hooks and create empty commits.
listed: true
dateModified: 2024-04-20
---
The building block of version control in Git is the **comm... | ---
title: Create a Git commit
shortTitle: Create commit
language: git
tags: [commit]
cover: cave-explorer
excerpt: Learn how to create a new commit in Git, along with tricks to skip Git hooks and create empty commits.
listed: true
dateModified: 2024-04-20
---
The building block of version control in Git is the **comm... | code_snippets | ||
61979532-860f-4c50-9470-16464b5e8fd1 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-fixup-commit.md | unknown | 880da7cf-c656-4309-a894-959ba6e5a22a | 2 | SemanticChunker@1.0.0 | 7e802b9a63301ce67131b66a15dc24256fdada82a10305df4d751b7d9baba245 | [Creating a fixup commit > Alias for creating fixup commits]
## Alias for creating fixup commits
As creating a fixup commit might be a very common operation, it's easy to create an **alias** for it. You can use `git config` to create an alias for creating fixup commits.
```shell
git config --global alias.fix 'commit... | unknown | unknown | [Creating a fixup commit > Alias for creating fixup commits]
## Alias for creating fixup commits
As creating a fixup commit might be a very common operation, it's easy to create an **alias** for it. You can use `git config` to create an alias for creating fixup commits.
```shell
git config --global alias.fix 'commit... | [Creating a fixup commit > Alias for creating fixup commits]
## Alias for creating fixup commits
As creating a fixup commit might be a very common operation, it's easy to create an **alias** for it. You can use `git config` to create an alias for creating fixup commits.
```shell
git config --global alias.fix 'commit... | code_snippets | ||
a776711d-6cb0-419d-99fc-d37580947374 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-fixup-commit.md | unknown | 880da7cf-c656-4309-a894-959ba6e5a22a | 1 | SemanticChunker@1.0.0 | 6c0cdb1c8a7572d45415a7ff459558a8a6502fb90459a4ef09fb41681ba600d9 | [Creating a fixup commit]
## Creating a fixup commit
Simply use `git commit --fixup <commit>` to create a fixup commit for the specified `<commit>`. After running `git rebase --autosquash`, fixup commits will be automatically squashed into the commits they reference.
> [!NOTE]
>
> You can learn more about Git's **in... | unknown | unknown | [Creating a fixup commit]
## Creating a fixup commit
Simply use `git commit --fixup <commit>` to create a fixup commit for the specified `<commit>`. After running `git rebase --autosquash`, fixup commits will be automatically squashed into the commits they reference.
> [!NOTE]
>
> You can learn more about Git's **in... | [Creating a fixup commit]
## Creating a fixup commit
Simply use `git commit --fixup <commit>` to create a fixup commit for the specified `<commit>`. After running `git rebase --autosquash`, fixup commits will be automatically squashed into the commits they reference.
> [!NOTE]
>
> You can learn more about Git's **in... | code_snippets | ||
b8ee199e-4441-4644-8351-16eab9a481f1 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-fixup-commit.md | unknown | 880da7cf-c656-4309-a894-959ba6e5a22a | 0 | SemanticChunker@1.0.0 | 6f16a2d750f811734489665faafb79949203aa3b37a463b92103f304f7fd8ab0 | ---
title: Create a fixup commit in Git
shortTitle: Create fixup commit
language: git
tags: [commit]
cover: tools
excerpt: If you find yourself needing to fix a previous commit, you can create a fixup commit that can be autosquashed in the next rebase.
listed: true
dateModified: 2024-05-02
---
If you find yourself nee... | unknown | unknown | ---
title: Create a fixup commit in Git
shortTitle: Create fixup commit
language: git
tags: [commit]
cover: tools
excerpt: If you find yourself needing to fix a previous commit, you can create a fixup commit that can be autosquashed in the next rebase.
listed: true
dateModified: 2024-05-02
---
If you find yourself nee... | ---
title: Create a fixup commit in Git
shortTitle: Create fixup commit
language: git
tags: [commit]
cover: tools
excerpt: If you find yourself needing to fix a previous commit, you can create a fixup commit that can be autosquashed in the next rebase.
listed: true
dateModified: 2024-05-02
---
If you find yourself nee... | code_snippets | ||
bd709671-9354-46a6-aa27-c683f1bb7513 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-fixup-commit.md | unknown | 880da7cf-c656-4309-a894-959ba6e5a22a | 3 | SemanticChunker@1.0.0 | 190cb4d33d1c028ef61518498996c63827d9dde9e4c6034558e08766c247dd48 | [Creating a fixup commit > Simplifying fixup commit creation]
## Simplifying fixup commit creation
Finding the commit hash to reference (e.g. using `tig`) can be cumbersome. Luckily, you can install `fzf` and add an alias that uses it to **select the commit hash interactively**. Then, you can use it to see the commit... | unknown | unknown | [Creating a fixup commit > Simplifying fixup commit creation]
## Simplifying fixup commit creation
Finding the commit hash to reference (e.g. using `tig`) can be cumbersome. Luckily, you can install `fzf` and add an alias that uses it to **select the commit hash interactively**. Then, you can use it to see the commit... | [Creating a fixup commit > Simplifying fixup commit creation]
## Simplifying fixup commit creation
Finding the commit hash to reference (e.g. using `tig`) can be cumbersome. Luckily, you can install `fzf` and add an alias that uses it to **select the commit hash interactively**. Then, you can use it to see the commit... | code_snippets | ||
aadf3457-692f-44df-adea-f63134f1c862 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-repo.md | unknown | aa76caa7-34b3-4e65-9252-9f568d0ef9c7 | 0 | SemanticChunker@1.0.0 | 3f158f5b88d64dafb0b9764945dac55070c1ba8eb90e7a645282dcd01089c1b3 | ---
title: Create a new Git repository
shortTitle: Create repository
language: git
tags: [repository]
cover: do-more-computer
excerpt: The first step is often the hardest, yet creating a Git repository is as simple as running a single command.
listed: true
dateModified: 2024-04-14
---
The first thing you need to do wh... | unknown | unknown | ---
title: Create a new Git repository
shortTitle: Create repository
language: git
tags: [repository]
cover: do-more-computer
excerpt: The first step is often the hardest, yet creating a Git repository is as simple as running a single command.
listed: true
dateModified: 2024-04-14
---
The first thing you need to do wh... | ---
title: Create a new Git repository
shortTitle: Create repository
language: git
tags: [repository]
cover: do-more-computer
excerpt: The first step is often the hardest, yet creating a Git repository is as simple as running a single command.
listed: true
dateModified: 2024-04-14
---
The first thing you need to do wh... | code_snippets | ||
58eec0b0-bcb8-4b7e-b991-4b91fcec2674 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/current-branch-name.md | unknown | 1b73e855-a0d9-42d7-8fac-10eb27906e7b | 0 | SemanticChunker@1.0.0 | f69cf9f801cb825eb3883754db9e9891d6972a40aeaddfde10ba4af5243c07ca | ---
title: Get the current branch name in Git
shortTitle: Current branch name
language: git
tags: [branch]
cover: cherry-trees
excerpt: Get the name of the current branch in Git.
listed: true
dateModified: 2024-04-22
---
The name of the current branch in Git can be useful for various purposes, such as **scripting**, d... | unknown | unknown | ---
title: Get the current branch name in Git
shortTitle: Current branch name
language: git
tags: [branch]
cover: cherry-trees
excerpt: Get the name of the current branch in Git.
listed: true
dateModified: 2024-04-22
---
The name of the current branch in Git can be useful for various purposes, such as **scripting**, d... | ---
title: Get the current branch name in Git
shortTitle: Current branch name
language: git
tags: [branch]
cover: cherry-trees
excerpt: Get the name of the current branch in Git.
listed: true
dateModified: 2024-04-22
---
The name of the current branch in Git can be useful for various purposes, such as **scripting**, d... | code_snippets | ||
e72b7383-d8b9-4875-95ee-a45c3685765e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-branch.md | unknown | b5411240-2949-4650-adfc-c5a5d13f28e4 | 0 | SemanticChunker@1.0.0 | 7d7e5716b511c649fa805be6f51fccd0b9617f9d26c3f83adc708003a90f68cb | ---
title: Create a new Git branch
shortTitle: Create branch
language: git
tags: [branch,remote]
cover: flower-pond
excerpt: Learn how to create a new Git branch and optionally set up a remote tracking branch.
listed: true
dateModified: 2024-04-28
---
Git branches are used to develop features, fix bugs, and experiment... | unknown | unknown | ---
title: Create a new Git branch
shortTitle: Create branch
language: git
tags: [branch,remote]
cover: flower-pond
excerpt: Learn how to create a new Git branch and optionally set up a remote tracking branch.
listed: true
dateModified: 2024-04-28
---
Git branches are used to develop features, fix bugs, and experiment... | ---
title: Create a new Git branch
shortTitle: Create branch
language: git
tags: [branch,remote]
cover: flower-pond
excerpt: Learn how to create a new Git branch and optionally set up a remote tracking branch.
listed: true
dateModified: 2024-04-28
---
Git branches are used to develop features, fix bugs, and experiment... | code_snippets | ||
e77a3b6c-29a3-4dce-a894-34ba2e20272e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-branch.md | unknown | b5411240-2949-4650-adfc-c5a5d13f28e4 | 2 | SemanticChunker@1.0.0 | 9f7a084357cc2c147276bf9ab3ca13028cac34d6da39e8d0c9bdae57f3e925e7 | [Create a new branch > Create an empty branch]
## Create an empty branch
If you want to create an **empty branch** without any history, you can use `git checkout --orphan <branch>`. This command creates a new branch with **no commit history**. This can be very useful for setting up branches with entirely different co... | unknown | unknown | [Create a new branch > Create an empty branch]
## Create an empty branch
If you want to create an **empty branch** without any history, you can use `git checkout --orphan <branch>`. This command creates a new branch with **no commit history**. This can be very useful for setting up branches with entirely different co... | [Create a new branch > Create an empty branch]
## Create an empty branch
If you want to create an **empty branch** without any history, you can use `git checkout --orphan <branch>`. This command creates a new branch with **no commit history**. This can be very useful for setting up branches with entirely different co... | code_snippets | ||
f293e265-5f3f-413f-bfdd-2611e3add10d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/create-branch.md | unknown | b5411240-2949-4650-adfc-c5a5d13f28e4 | 1 | SemanticChunker@1.0.0 | 1e6ef8902352701cd153d30794009cb156a9978a7a25cb54d6a754e26a9ae34f | [Create a new branch]
## Create a new branch
Creating a new branch is as simple as using `git checkout -b <branch>`. This command creates a new branch with the **specified name** and switches to it. You can also set up a **remote tracking branch** for the newly created branch by adding `-t <remote>/<branch>`.
> [!TI... | unknown | unknown | [Create a new branch]
## Create a new branch
Creating a new branch is as simple as using `git checkout -b <branch>`. This command creates a new branch with the **specified name** and switches to it. You can also set up a **remote tracking branch** for the newly created branch by adding `-t <remote>/<branch>`.
> [!TI... | [Create a new branch]
## Create a new branch
Creating a new branch is as simple as using `git checkout -b <branch>`. This command creates a new branch with the **specified name** and switches to it. You can also set up a **remote tracking branch** for the newly created branch by adding `-t <remote>/<branch>`.
> [!TI... | code_snippets | ||
21a0c530-8e10-4401-94d2-b58684accae0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/copy-file-from-branch.md | unknown | baf64aaa-e8a1-4986-80e4-003ac15bdd82 | 0 | SemanticChunker@1.0.0 | 6ac92dabaa58d1cbb23bba88061f69ff3dab7c0b3f578c5a4c8217748279c48d | ---
title: How can I copy a file from another Git branch?
shortTitle: Copy file from another branch
language: git
tags: [branch]
cover: sea-view-2
excerpt: If you need to copy a file from another branch to the current branch, here's an easy way to do it.
listed: true
dateModified: 2024-04-16
---
A scenario I've run in... | unknown | unknown | ---
title: How can I copy a file from another Git branch?
shortTitle: Copy file from another branch
language: git
tags: [branch]
cover: sea-view-2
excerpt: If you need to copy a file from another branch to the current branch, here's an easy way to do it.
listed: true
dateModified: 2024-04-16
---
A scenario I've run in... | ---
title: How can I copy a file from another Git branch?
shortTitle: Copy file from another branch
language: git
tags: [branch]
cover: sea-view-2
excerpt: If you need to copy a file from another branch to the current branch, here's an easy way to do it.
listed: true
dateModified: 2024-04-16
---
A scenario I've run in... | code_snippets | ||
9ee95f02-859b-4841-854c-3fc12beafaa7 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-merge-commit.md | unknown | 99535c06-0a03-42ab-aba2-16a17a527de4 | 0 | SemanticChunker@1.0.0 | c068d688ec12e6aab9c5be03acd3356f74b2388bfcd4d99789fda5d2729741ef | ---
title: How can I find the merge commit given a Git commit?
shortTitle: Merge commit for a commit
language: git
tags: [commit]
cover: travel-mug-1
excerpt: Looking for the merge commit where the changes from a given commit were merged into a branch? Here's how you can find it.
listed: true
dateModified: 2024-05-04
-... | unknown | unknown | ---
title: How can I find the merge commit given a Git commit?
shortTitle: Merge commit for a commit
language: git
tags: [commit]
cover: travel-mug-1
excerpt: Looking for the merge commit where the changes from a given commit were merged into a branch? Here's how you can find it.
listed: true
dateModified: 2024-05-04
-... | ---
title: How can I find the merge commit given a Git commit?
shortTitle: Merge commit for a commit
language: git
tags: [commit]
cover: travel-mug-1
excerpt: Looking for the merge commit where the changes from a given commit were merged into a branch? Here's how you can find it.
listed: true
dateModified: 2024-05-04
-... | code_snippets | ||
7e908ef6-8c4a-4ea0-90ea-a7b3432887ae | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/force-update-remote-branch.md | unknown | 0157e42d-0fca-4d4d-9ee8-ea907257ae51 | 0 | SemanticChunker@1.0.0 | 17876324f80900a7f655e22b52b66d638b5eded77850c7b87181260ed5be753d | ---
title: How can I update a remote branch after rewriting Git history?
shortTitle: Update remote branch after rewriting history
language: git
tags: [branch]
cover: compass
excerpt: Learn how to force update a remote branch after rewriting the Git history locally.
listed: true
dateModified: 2024-04-15
---
When you re... | unknown | unknown | ---
title: How can I update a remote branch after rewriting Git history?
shortTitle: Update remote branch after rewriting history
language: git
tags: [branch]
cover: compass
excerpt: Learn how to force update a remote branch after rewriting the Git history locally.
listed: true
dateModified: 2024-04-15
---
When you re... | ---
title: How can I update a remote branch after rewriting Git history?
shortTitle: Update remote branch after rewriting history
language: git
tags: [branch]
cover: compass
excerpt: Learn how to force update a remote branch after rewriting the Git history locally.
listed: true
dateModified: 2024-04-15
---
When you re... | code_snippets | ||
04a86b10-90c5-4cfb-94e8-95c52d22983d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 7 | SemanticChunker@1.0.0 | 1bd425c5c5379de8b82e4ec5a21b58a50f12821874cde6e3b85707558a1b1807 | [Limit results > Limit to a specific commit]
### Limit to a specific commit
If you want to search only in a **specific commit**, you can use `git grep <pattern> <commit>`. This will limit the search to the files in the specified commit.
```shell
# Syntax: git grep <pattern> <commit>
git grep "TODO" HEAD~1
# Returns... | unknown | unknown | [Limit results > Limit to a specific commit]
### Limit to a specific commit
If you want to search only in a **specific commit**, you can use `git grep <pattern> <commit>`. This will limit the search to the files in the specified commit.
```shell
# Syntax: git grep <pattern> <commit>
git grep "TODO" HEAD~1
# Returns... | [Limit results > Limit to a specific commit]
### Limit to a specific commit
If you want to search only in a **specific commit**, you can use `git grep <pattern> <commit>`. This will limit the search to the files in the specified commit.
```shell
# Syntax: git grep <pattern> <commit>
git grep "TODO" HEAD~1
# Returns... | code_snippets | ||
15b7c2bc-bcfd-4ef8-9b19-057986a6f85f | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 4 | SemanticChunker@1.0.0 | 9a4fadff67c9b7693e2ffd70ebb7d51d24628c050efe355b6afb8f141a43d793 | [Find files matching a pattern > Limit results]
## Limit results
By default, `git grep` will return all files that match the pattern. If you want to limit the results, there are various ways to do so. | unknown | unknown | [Find files matching a pattern > Limit results]
## Limit results
By default, `git grep` will return all files that match the pattern. If you want to limit the results, there are various ways to do so. | [Find files matching a pattern > Limit results]
## Limit results
By default, `git grep` will return all files that match the pattern. If you want to limit the results, there are various ways to do so. | code_snippets | ||
19e6d53b-e6bb-4b9e-8579-54f6daa7a683 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 3 | SemanticChunker@1.0.0 | f2220a08d345b49a4c0a45e999406df52b668fcea38452d605d4309ef591c398 | [Multi-pattern search > Case-insensitive search]
### Case-insensitive search
By default, `git grep` is case-sensitive. If you want to search for **case-insensitive** patterns, you can use the `-i` flag.
```shell
# Syntax: git grep -i <pattern>
git grep -i "todo"
# Returns all files that contain the word "TODO" in a... | unknown | unknown | [Multi-pattern search > Case-insensitive search]
### Case-insensitive search
By default, `git grep` is case-sensitive. If you want to search for **case-insensitive** patterns, you can use the `-i` flag.
```shell
# Syntax: git grep -i <pattern>
git grep -i "todo"
# Returns all files that contain the word "TODO" in a... | [Multi-pattern search > Case-insensitive search]
### Case-insensitive search
By default, `git grep` is case-sensitive. If you want to search for **case-insensitive** patterns, you can use the `-i` flag.
```shell
# Syntax: git grep -i <pattern>
git grep -i "todo"
# Returns all files that contain the word "TODO" in a... | code_snippets | ||
45ed0868-7fec-4c8f-84f3-61b6a92d7883 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 9 | SemanticChunker@1.0.0 | bdd44cd22445dd8f183f69c894c86fc0056e11974acf08884535f4dc131093c4 | [Find files matching a pattern > Format the output]
## Format the output
As the results of `git grep` can be quite long, there are a handful of formatting options, you can use to make them more readable. | unknown | unknown | [Find files matching a pattern > Format the output]
## Format the output
As the results of `git grep` can be quite long, there are a handful of formatting options, you can use to make them more readable. | [Find files matching a pattern > Format the output]
## Format the output
As the results of `git grep` can be quite long, there are a handful of formatting options, you can use to make them more readable. | code_snippets | ||
4d2bd451-ce91-4ac4-ae56-81e7b9d78186 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 8 | SemanticChunker@1.0.0 | 73106b70e364a5b0463608bee0c28620f66dd33d2a726c1a8d4fdaf1e88d07f7 | [Limit results > Limit in a specific branch]
### Limit in a specific branch
Searching in a **specific branch** is similar to searching in a specific commit. You can use `git grep <pattern> <branch>` to search in the files of the specified branch.
```shell
# Syntax: git grep <pattern> <branch>
git grep "TODO" master... | unknown | unknown | [Limit results > Limit in a specific branch]
### Limit in a specific branch
Searching in a **specific branch** is similar to searching in a specific commit. You can use `git grep <pattern> <branch>` to search in the files of the specified branch.
```shell
# Syntax: git grep <pattern> <branch>
git grep "TODO" master... | [Limit results > Limit in a specific branch]
### Limit in a specific branch
Searching in a **specific branch** is similar to searching in a specific commit. You can use `git grep <pattern> <branch>` to search in the files of the specified branch.
```shell
# Syntax: git grep <pattern> <branch>
git grep "TODO" master... | code_snippets | ||
5bf795e1-b995-4c1c-9d1b-91ef7651e61b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 12 | SemanticChunker@1.0.0 | 10dd2d8c8c9737d9f2ae534446dfdb68c340b974078228a5b297d7f54ad72a31 | [Format the output > Show the number of matches]
### Show the number of matches
If you want to know how many matches there are in each file, you can use the `-c` flag to show the **count of matches** for each file.
```shell
# Syntax: git grep -c <pattern>
git grep -c "TODO"
# Returns the count of matches for the wo... | unknown | unknown | [Format the output > Show the number of matches]
### Show the number of matches
If you want to know how many matches there are in each file, you can use the `-c` flag to show the **count of matches** for each file.
```shell
# Syntax: git grep -c <pattern>
git grep -c "TODO"
# Returns the count of matches for the wo... | [Format the output > Show the number of matches]
### Show the number of matches
If you want to know how many matches there are in each file, you can use the `-c` flag to show the **count of matches** for each file.
```shell
# Syntax: git grep -c <pattern>
git grep -c "TODO"
# Returns the count of matches for the wo... | code_snippets | ||
686b4a7d-d346-45c0-91ea-ebd59c67775a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 0 | SemanticChunker@1.0.0 | 5e50d7466f6132b1e684b91c048f478efbb49f6a38933b648d8c5f7a6fa5a742 | ---
title: Use Git to find matching files
shortTitle: Find matching files
language: git
tags: [repository,branch,commit]
cover: boulder-beach
excerpt: Learn how to leverage the power of `git grep` to find matching files in your repository.
listed: true
dateModified: 2024-05-06
---
If you've spent any time in the comma... | unknown | unknown | ---
title: Use Git to find matching files
shortTitle: Find matching files
language: git
tags: [repository,branch,commit]
cover: boulder-beach
excerpt: Learn how to leverage the power of `git grep` to find matching files in your repository.
listed: true
dateModified: 2024-05-06
---
If you've spent any time in the comma... | ---
title: Use Git to find matching files
shortTitle: Find matching files
language: git
tags: [repository,branch,commit]
cover: boulder-beach
excerpt: Learn how to leverage the power of `git grep` to find matching files in your repository.
listed: true
dateModified: 2024-05-06
---
If you've spent any time in the comma... | code_snippets | ||
6de077d4-de4b-4ad1-85e3-24152e8e8d36 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 2 | SemanticChunker@1.0.0 | 1b7a870f303c268e23bf4c5c1a6f81b45315300a7ec5332912369e29a72f8972 | [Find files matching a pattern > Multi-pattern search]
### Multi-pattern search
You can search for **multiple patterns** combining them using the `--or` or `--and` flags. The `--or` flag will return files that match any of the patterns, while the `--and` flag will return files that match all of the patterns.
```shel... | unknown | unknown | [Find files matching a pattern > Multi-pattern search]
### Multi-pattern search
You can search for **multiple patterns** combining them using the `--or` or `--and` flags. The `--or` flag will return files that match any of the patterns, while the `--and` flag will return files that match all of the patterns.
```shel... | [Find files matching a pattern > Multi-pattern search]
### Multi-pattern search
You can search for **multiple patterns** combining them using the `--or` or `--and` flags. The `--or` flag will return files that match any of the patterns, while the `--and` flag will return files that match all of the patterns.
```shel... | code_snippets | ||
75187724-1587-4dbb-9988-533411571ae6 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 10 | SemanticChunker@1.0.0 | e1b81b892dd038edf97554d40c0a164523a60d3c65f5a8d9673a257adace5a4f | [Format the output > Show line numbers]
### Show line numbers
You can use the `-n` flag to **show line numbers** in the output. This will add the line number between the file name and the matched line.
```shell
# Syntax: git grep -n <pattern>
git grep -n "TODO"
# Returns all files that contain the word "TODO" with ... | unknown | unknown | [Format the output > Show line numbers]
### Show line numbers
You can use the `-n` flag to **show line numbers** in the output. This will add the line number between the file name and the matched line.
```shell
# Syntax: git grep -n <pattern>
git grep -n "TODO"
# Returns all files that contain the word "TODO" with ... | [Format the output > Show line numbers]
### Show line numbers
You can use the `-n` flag to **show line numbers** in the output. This will add the line number between the file name and the matched line.
```shell
# Syntax: git grep -n <pattern>
git grep -n "TODO"
# Returns all files that contain the word "TODO" with ... | code_snippets | ||
b96571a5-9619-4de7-97e3-14d34bba75c2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 5 | SemanticChunker@1.0.0 | 81a559c9d3251d14f901d53b0228cb509ab4c4a9575c1de69046170b063462b5 | [Limit results > Limit to a specific file extension]
### Limit to a specific file extension
If you want to search only in files with a **specific extension**, you can use `git grep <pattern> -- <pathspec>`. This will limit the search to files with the specified extension.
```shell
# Syntax: git grep <pattern> -- <pa... | unknown | unknown | [Limit results > Limit to a specific file extension]
### Limit to a specific file extension
If you want to search only in files with a **specific extension**, you can use `git grep <pattern> -- <pathspec>`. This will limit the search to files with the specified extension.
```shell
# Syntax: git grep <pattern> -- <pa... | [Limit results > Limit to a specific file extension]
### Limit to a specific file extension
If you want to search only in files with a **specific extension**, you can use `git grep <pattern> -- <pathspec>`. This will limit the search to files with the specified extension.
```shell
# Syntax: git grep <pattern> -- <pa... | code_snippets | ||
d842e5d8-afaf-4737-8f98-1cacf360852e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 1 | SemanticChunker@1.0.0 | 78ba9cc0ea0ec8aec1755a6b54f6572de597a5a8a88b542b30ea15eb31655f99 | [Find files matching a pattern]
## Find files matching a pattern
Using `git grep <pattern>` you can search for files in your repository that match a specific pattern. **Regular expressions** are supported, so you can use all the power of regex to find exactly what you're looking for.
```shell
# Syntax: git grep <pat... | unknown | unknown | [Find files matching a pattern]
## Find files matching a pattern
Using `git grep <pattern>` you can search for files in your repository that match a specific pattern. **Regular expressions** are supported, so you can use all the power of regex to find exactly what you're looking for.
```shell
# Syntax: git grep <pat... | [Find files matching a pattern]
## Find files matching a pattern
Using `git grep <pattern>` you can search for files in your repository that match a specific pattern. **Regular expressions** are supported, so you can use all the power of regex to find exactly what you're looking for.
```shell
# Syntax: git grep <pat... | code_snippets | ||
da6d8443-8a81-4313-b7c9-1f88d7864f6c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 11 | SemanticChunker@1.0.0 | 8a6110ad166575d749ebcca5c727a74b5060faa224b11409e26c981b7ff3081e | [Format the output > Show file names only]
### Show file names only
Instead of showing every matched line, you can use the `-l` flag to **show only the file names** that contain the pattern.
```shell
# Syntax: git grep -l <pattern>
git grep -l "TODO"
# Returns only the file names that contain the word "TODO"
``` | unknown | unknown | [Format the output > Show file names only]
### Show file names only
Instead of showing every matched line, you can use the `-l` flag to **show only the file names** that contain the pattern.
```shell
# Syntax: git grep -l <pattern>
git grep -l "TODO"
# Returns only the file names that contain the word "TODO"
``` | [Format the output > Show file names only]
### Show file names only
Instead of showing every matched line, you can use the `-l` flag to **show only the file names** that contain the pattern.
```shell
# Syntax: git grep -l <pattern>
git grep -l "TODO"
# Returns only the file names that contain the word "TODO"
``` | code_snippets | ||
e4c5e594-2562-44bf-8138-ea6efc8b783a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-matching-files.md | unknown | fc487dba-8ec1-42e2-b7fb-c4919ddb111a | 6 | SemanticChunker@1.0.0 | b91b623a2351b7711f6da5ef6754dbcdf93855cfbf7c5d4d898bb1ecdd2c4c9f | [Limit results > Limit to a specific directory]
### Limit to a specific directory
Similarly, you can use `git grep <pattern> -- <pathspec>` to search only in a **specific directory**. You can also use `:^` to **exclude** files from a specific directory.
```shell
# Syntax: git grep <pattern> -- <pathspec>
git grep "... | unknown | unknown | [Limit results > Limit to a specific directory]
### Limit to a specific directory
Similarly, you can use `git grep <pattern> -- <pathspec>` to search only in a **specific directory**. You can also use `:^` to **exclude** files from a specific directory.
```shell
# Syntax: git grep <pattern> -- <pathspec>
git grep "... | [Limit results > Limit to a specific directory]
### Limit to a specific directory
Similarly, you can use `git grep <pattern> -- <pathspec>` to search only in a **specific directory**. You can also use `:^` to **exclude** files from a specific directory.
```shell
# Syntax: git grep <pattern> -- <pathspec>
git grep "... | code_snippets | ||
8793fb20-e605-4b28-abb8-6aed765fdadc | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/fix-incorrect-line-endings.md | unknown | c5762cc0-d541-48d5-bdb8-02c4db7edabf | 1 | SemanticChunker@1.0.0 | e1a91d4f9cc373a92bbee5bbbcdfaf70800446463624047bd7d550a8da91dd64 | ```shell
# Re-check all files and apply the new line ending settings
git add --renormalize .
```
These two commands fixed the issue without messing up the repository's history. After running these commands, the Ruby script could be executed without any issues and we were back on track. Hopefully, this little tip will ... | unknown | unknown | ```shell
# Re-check all files and apply the new line ending settings
git add --renormalize .
```
These two commands fixed the issue without messing up the repository's history. After running these commands, the Ruby script could be executed without any issues and we were back on track. Hopefully, this little tip will ... | ```shell
# Re-check all files and apply the new line ending settings
git add --renormalize .
```
These two commands fixed the issue without messing up the repository's history. After running these commands, the Ruby script could be executed without any issues and we were back on track. Hopefully, this little tip will ... | code_snippets | ||
dd1aa16b-4de7-4982-9dcb-7d1bc0388daa | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/fix-incorrect-line-endings.md | unknown | c5762cc0-d541-48d5-bdb8-02c4db7edabf | 0 | SemanticChunker@1.0.0 | cfd2c7b885345679142a44a2b8e07343e1764bbf90c2282ecf8939c2b1fffea7 | ---
title: How do I fix incorrect line endings in a git repository?
shortTitle: Fix incorrect line endings
language: git
tags: [configuration,repository]
cover: laptop-off
excerpt: Have you ever encountered an issue with incorrect line endings in your git repository? Let's fix it!
listed: true
dateModified: 2025-09-08
... | unknown | unknown | ---
title: How do I fix incorrect line endings in a git repository?
shortTitle: Fix incorrect line endings
language: git
tags: [configuration,repository]
cover: laptop-off
excerpt: Have you ever encountered an issue with incorrect line endings in your git repository? Let's fix it!
listed: true
dateModified: 2025-09-08
... | ---
title: How do I fix incorrect line endings in a git repository?
shortTitle: Fix incorrect line endings
language: git
tags: [configuration,repository]
cover: laptop-off
excerpt: Have you ever encountered an issue with incorrect line endings in your git repository? Let's fix it!
listed: true
dateModified: 2025-09-08
... | code_snippets | ||
457dcccb-b841-487c-8fbf-226bf1d8f433 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/force-push-better-alternative.md | unknown | 6e1ed2da-3986-4ab3-8be9-1bb9321c857f | 0 | SemanticChunker@1.0.0 | 81d71d0c8e198604f5422202fbbdcd52133518b5ef7f8edea77ef85187f33402 | ---
title: A better alternative to force pushing
shortTitle: Safe force push alternative
language: git
tags: [repository,branch]
cover: home-office
excerpt: Forced pushes in shared branches are dangerous, but did you know there's a safer alternative?
listed: true
dateModified: 2026-01-28
---
I've been using `git push ... | unknown | unknown | ---
title: A better alternative to force pushing
shortTitle: Safe force push alternative
language: git
tags: [repository,branch]
cover: home-office
excerpt: Forced pushes in shared branches are dangerous, but did you know there's a safer alternative?
listed: true
dateModified: 2026-01-28
---
I've been using `git push ... | ---
title: A better alternative to force pushing
shortTitle: Safe force push alternative
language: git
tags: [repository,branch]
cover: home-office
excerpt: Forced pushes in shared branches are dangerous, but did you know there's a safer alternative?
listed: true
dateModified: 2026-01-28
---
I've been using `git push ... | code_snippets | ||
7fda197c-5465-44ec-a59f-288f7de9c1aa | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-lost-files.md | unknown | 26227cf4-4585-40c7-813a-456e5085a1c4 | 0 | SemanticChunker@1.0.0 | c463bac0f893cc43246a1a711425392ba2cd5e94e92f9ec17cd999d3068ce98b | ---
title: Find lost files using Git
shortTitle: Find lost files
language: git
tags: [repository]
cover: hard-disk
excerpt: Learn how to find lost files and commits in a Git repository.
listed: true
dateModified: 2024-05-01
---
If you've **lost files or commits** in your Git repository, you can use the `git fsck` comm... | unknown | unknown | ---
title: Find lost files using Git
shortTitle: Find lost files
language: git
tags: [repository]
cover: hard-disk
excerpt: Learn how to find lost files and commits in a Git repository.
listed: true
dateModified: 2024-05-01
---
If you've **lost files or commits** in your Git repository, you can use the `git fsck` comm... | ---
title: Find lost files using Git
shortTitle: Find lost files
language: git
tags: [repository]
cover: hard-disk
excerpt: Learn how to find lost files and commits in a Git repository.
listed: true
dateModified: 2024-05-01
---
If you've **lost files or commits** in your Git repository, you can use the `git fsck` comm... | code_snippets | ||
15ca27e4-4120-4994-86d4-16b81f2d6eba | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-commit-with-bug.md | unknown | f5171f7c-a323-4e69-a038-3c8ddf53f416 | 1 | SemanticChunker@1.0.0 | 37ec5560647cab33535f576ef1d6862b340fcf4097a1fe548f5b8d98ac1ef150 | [Manually find the commit with a bug]
## Manually find the commit with a bug
In order to start the process, you need to use `git bisect start`. You need to first **mark a commit as "good"**, indicating it is known to be bug-free, and **another commit as "bad"**, indicating it has the bug. You can do so using `git bis... | unknown | unknown | [Manually find the commit with a bug]
## Manually find the commit with a bug
In order to start the process, you need to use `git bisect start`. You need to first **mark a commit as "good"**, indicating it is known to be bug-free, and **another commit as "bad"**, indicating it has the bug. You can do so using `git bis... | [Manually find the commit with a bug]
## Manually find the commit with a bug
In order to start the process, you need to use `git bisect start`. You need to first **mark a commit as "good"**, indicating it is known to be bug-free, and **another commit as "bad"**, indicating it has the bug. You can do so using `git bis... | code_snippets | ||
6ce32f3e-210c-472f-b337-50e2bc6b9afe | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-commit-with-bug.md | unknown | f5171f7c-a323-4e69-a038-3c8ddf53f416 | 0 | SemanticChunker@1.0.0 | bf678e7d4302a08c8a6fbc1310e0b3fcbe18fb128a4120bcfaa6714beb4506e0 | ---
title: Find the Git commit that introduced a bug
shortTitle: Find commit with bug
language: git
tags: [commit,branch]
cover: pink-flower-tree
excerpt: Manually or automatically find which commit in history introduced a bug using.
listed: true
dateModified: 2024-03-27
---
Git's **bisect** command is a powerful, yet... | unknown | unknown | ---
title: Find the Git commit that introduced a bug
shortTitle: Find commit with bug
language: git
tags: [commit,branch]
cover: pink-flower-tree
excerpt: Manually or automatically find which commit in history introduced a bug using.
listed: true
dateModified: 2024-03-27
---
Git's **bisect** command is a powerful, yet... | ---
title: Find the Git commit that introduced a bug
shortTitle: Find commit with bug
language: git
tags: [commit,branch]
cover: pink-flower-tree
excerpt: Manually or automatically find which commit in history introduced a bug using.
listed: true
dateModified: 2024-03-27
---
Git's **bisect** command is a powerful, yet... | code_snippets | ||
e44dc186-d01e-4f03-b175-786ea53db73c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/find-commit-with-bug.md | unknown | f5171f7c-a323-4e69-a038-3c8ddf53f416 | 2 | SemanticChunker@1.0.0 | ff9285a6de0cac1a28fba76e02729c7ffd4b49f4111dc0cb2a8358fddc9fe31c | [Manually find the commit with a bug > Automatically find the commit with a bug]
## Automatically find the commit with a bug
If all of that seems like too much work, thankfully you can automate the process using `git bisect run`. This command will **run a given script on each subsequent commit** to find which commit ... | unknown | unknown | [Manually find the commit with a bug > Automatically find the commit with a bug]
## Automatically find the commit with a bug
If all of that seems like too much work, thankfully you can automate the process using `git bisect run`. This command will **run a given script on each subsequent commit** to find which commit ... | [Manually find the commit with a bug > Automatically find the commit with a bug]
## Automatically find the commit with a bug
If all of that seems like too much work, thankfully you can automate the process using `git bisect run`. This command will **run a given script on each subsequent commit** to find which commit ... | code_snippets | ||
2177bcfc-2e48-45b6-8b6b-d51fc267f669 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/fast-forward-merge.md | unknown | 5d3e0f1d-4ada-4043-bc4a-b410f1a48594 | 1 | SemanticChunker@1.0.0 | 64a14847a6ce69119c1e1b5bbb704d93ce7df75a2f4bad6db0f222d95b1d4d31 | [Fast-forward merge]
## Fast-forward merge
As stated above, Git's default is to use fast-forward merge. It will take the commits from the branch being merged and place them at the tip of the branch you're merging into. This creates a **linear history**, which is also the main advantage of using fast-forward merge. If... | unknown | unknown | [Fast-forward merge]
## Fast-forward merge
As stated above, Git's default is to use fast-forward merge. It will take the commits from the branch being merged and place them at the tip of the branch you're merging into. This creates a **linear history**, which is also the main advantage of using fast-forward merge. If... | [Fast-forward merge]
## Fast-forward merge
As stated above, Git's default is to use fast-forward merge. It will take the commits from the branch being merged and place them at the tip of the branch you're merging into. This creates a **linear history**, which is also the main advantage of using fast-forward merge. If... | code_snippets | ||
5626d2ad-cb72-42b4-87cc-0760678ed5da | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/fast-forward-merge.md | unknown | 5d3e0f1d-4ada-4043-bc4a-b410f1a48594 | 0 | SemanticChunker@1.0.0 | 466e86a6b34156fbf24de48ded3021481c30fb694abfcb698c4e6f1c2565aeca | ---
title: How does Git's fast-forward mode work?
shortTitle: Fast-forward merge
language: git
tags: [branch]
cover: boats
excerpt: Learn about Git's fast-forward mode and its benefits when merging branches, so you can decide if it's a good fit for you and your team.
listed: true
dateModified: 2021-07-15
---
Merging a... | unknown | unknown | ---
title: How does Git's fast-forward mode work?
shortTitle: Fast-forward merge
language: git
tags: [branch]
cover: boats
excerpt: Learn about Git's fast-forward mode and its benefits when merging branches, so you can decide if it's a good fit for you and your team.
listed: true
dateModified: 2021-07-15
---
Merging a... | ---
title: How does Git's fast-forward mode work?
shortTitle: Fast-forward merge
language: git
tags: [branch]
cover: boats
excerpt: Learn about Git's fast-forward mode and its benefits when merging branches, so you can decide if it's a good fit for you and your team.
listed: true
dateModified: 2021-07-15
---
Merging a... | code_snippets | ||
bb28c5d0-b4ea-4cc8-ba2c-325247f9dbe7 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/fast-forward-merge.md | unknown | 5d3e0f1d-4ada-4043-bc4a-b410f1a48594 | 2 | SemanticChunker@1.0.0 | dba6669f478e65cc7d9eca6e39550eeedac285eb0c4f395e4d93f0a5c2b4391d | [Fast-forward merge > Non fast-forward merge]
## Non fast-forward merge
GitHub, on the other hand, uses non fast-forward merge by default. It will create a merge commit at the tip of the branch you're merging into, optionally referencing the branch being merged in the commit message. This has the advantage of **keepi... | unknown | unknown | [Fast-forward merge > Non fast-forward merge]
## Non fast-forward merge
GitHub, on the other hand, uses non fast-forward merge by default. It will create a merge commit at the tip of the branch you're merging into, optionally referencing the branch being merged in the commit message. This has the advantage of **keepi... | [Fast-forward merge > Non fast-forward merge]
## Non fast-forward merge
GitHub, on the other hand, uses non fast-forward merge by default. It will create a merge commit at the tip of the branch you're merging into, optionally referencing the branch being merged in the commit message. This has the advantage of **keepi... | code_snippets | ||
11ce8f11-8559-4e71-8c8d-4915cf779fa0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/fetch-changes.md | unknown | d8e65efe-08ab-4248-8c52-73067cf8d8ad | 0 | SemanticChunker@1.0.0 | 5177c46510526fe58e80bd33fe112bdf94fbc8582e7862ef74bd7ce50224c524 | ---
title: Fetch latest Git changes from the remote repository
shortTitle: Fetch latest changes
language: git
tags: [repository]
cover: playing-fetch
excerpt: Learn how to fetch the latest changes from the remote repository in Git and keep your local repository up to date.
listed: true
dateModified: 2024-04-19
---
Kee... | unknown | unknown | ---
title: Fetch latest Git changes from the remote repository
shortTitle: Fetch latest changes
language: git
tags: [repository]
cover: playing-fetch
excerpt: Learn how to fetch the latest changes from the remote repository in Git and keep your local repository up to date.
listed: true
dateModified: 2024-04-19
---
Kee... | ---
title: Fetch latest Git changes from the remote repository
shortTitle: Fetch latest changes
language: git
tags: [repository]
cover: playing-fetch
excerpt: Learn how to fetch the latest changes from the remote repository in Git and keep your local repository up to date.
listed: true
dateModified: 2024-04-19
---
Kee... | code_snippets | ||
ccefc2bd-52ce-4783-a75e-86b7345bf232 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/edit-config.md | unknown | 5b364f49-e7d3-46c0-ae8c-81d53a0daee0 | 0 | SemanticChunker@1.0.0 | 2cd45b77a712114eddc5015fd37776bc5982657f1ac2ea7594335feb9cb880b5 | ---
title: Edit the Git configuration file
shortTitle: Edit config
language: git
tags: [configuration]
cover: terminal
excerpt: Learn how to open the Git configuration file in the Git text editor, for editing.
listed: true
dateModified: 2024-04-11
---
Using `git config` a dozen times to set up your Git configuration c... | unknown | unknown | ---
title: Edit the Git configuration file
shortTitle: Edit config
language: git
tags: [configuration]
cover: terminal
excerpt: Learn how to open the Git configuration file in the Git text editor, for editing.
listed: true
dateModified: 2024-04-11
---
Using `git config` a dozen times to set up your Git configuration c... | ---
title: Edit the Git configuration file
shortTitle: Edit config
language: git
tags: [configuration]
cover: terminal
excerpt: Learn how to open the Git configuration file in the Git text editor, for editing.
listed: true
dateModified: 2024-04-11
---
Using `git config` a dozen times to set up your Git configuration c... | code_snippets | ||
adedaea3-c9aa-47c7-9a04-7a8063f15c71 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/optimize-repository.md | unknown | f956ef86-b70a-41fe-9ea0-899397899a04 | 0 | SemanticChunker@1.0.0 | 2900ce580dd728c4a6a5405a86f21d6b12704bcefecb9dd08f96fd9d083e279e | ---
title: Optimize the local Git repository
shortTitle: Optimize local repository
language: git
tags: [repository]
cover: automaton
excerpt: Is your Git repository getting bloated? Optimize it by garbage collecting loose objects.
listed: true
dateModified: 2024-04-13
---
Is your Git repository getting bloated? Maybe ... | unknown | unknown | ---
title: Optimize the local Git repository
shortTitle: Optimize local repository
language: git
tags: [repository]
cover: automaton
excerpt: Is your Git repository getting bloated? Optimize it by garbage collecting loose objects.
listed: true
dateModified: 2024-04-13
---
Is your Git repository getting bloated? Maybe ... | ---
title: Optimize the local Git repository
shortTitle: Optimize local repository
language: git
tags: [repository]
cover: automaton
excerpt: Is your Git repository getting bloated? Optimize it by garbage collecting loose objects.
listed: true
dateModified: 2024-04-13
---
Is your Git repository getting bloated? Maybe ... | code_snippets | ||
b7fd9a0b-bf1f-448b-b701-151bca41d10e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/pick-commits.md | unknown | 5990415f-75a5-47fe-8498-a5778840d61a | 0 | SemanticChunker@1.0.0 | 898aedad708685f3fb4342b2133fb3a29264617aeb6384f906cfa433db882446 | ---
title: Pick changes from one or more Git commits
shortTitle: Pick commits
language: git
tags: [commit,branch]
cover: sunflowers
excerpt: Learn how to apply changes introduced by one or more commits to your current branch (cherry-picking).
listed: true
dateModified: 2024-04-16
---
Oftentimes, working on one feature... | unknown | unknown | ---
title: Pick changes from one or more Git commits
shortTitle: Pick commits
language: git
tags: [commit,branch]
cover: sunflowers
excerpt: Learn how to apply changes introduced by one or more commits to your current branch (cherry-picking).
listed: true
dateModified: 2024-04-16
---
Oftentimes, working on one feature... | ---
title: Pick changes from one or more Git commits
shortTitle: Pick commits
language: git
tags: [commit,branch]
cover: sunflowers
excerpt: Learn how to apply changes introduced by one or more commits to your current branch (cherry-picking).
listed: true
dateModified: 2024-04-16
---
Oftentimes, working on one feature... | code_snippets | ||
5de26a0b-0154-4212-995d-73a8a7dcc1ca | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/merge-branch-merge-commit.md | unknown | 9c935ce4-050c-4f0d-816e-6e48b05016b1 | 2 | SemanticChunker@1.0.0 | dd679897e7875d47d1ee84ad91bd77b5f1d16359bb79f4d8b20fc5d3242107e3 | [Merging a branch > Creating a merge commit]
## Creating a merge commit
If, instead, you want to **create a merge commit**, you can use the `--no-ff` flag when merging. This will create a merge commit at the tip of the target branch, optionally referencing the source branch in the commit message. The rest of the proc... | unknown | unknown | [Merging a branch > Creating a merge commit]
## Creating a merge commit
If, instead, you want to **create a merge commit**, you can use the `--no-ff` flag when merging. This will create a merge commit at the tip of the target branch, optionally referencing the source branch in the commit message. The rest of the proc... | [Merging a branch > Creating a merge commit]
## Creating a merge commit
If, instead, you want to **create a merge commit**, you can use the `--no-ff` flag when merging. This will create a merge commit at the tip of the target branch, optionally referencing the source branch in the commit message. The rest of the proc... | code_snippets | ||
c1cb33b2-5ef1-4ecc-bb17-c73fdb9cdd30 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/merge-branch-merge-commit.md | unknown | 9c935ce4-050c-4f0d-816e-6e48b05016b1 | 1 | SemanticChunker@1.0.0 | a639aa0b584549c50912915eed7128538b04c3b455543db5c7836c9dbe54f6cf | [Merging a branch]
## Merging a branch
In order to merge a branch, you want to **switch to the target branch** first, using `git checkout`. Then, you can use `git merge` to **merge the source branch into the target branch**.
```shell
# Syntax:
# git checkout <target-branch>
# git merge <source-branch>
git checkout ... | unknown | unknown | [Merging a branch]
## Merging a branch
In order to merge a branch, you want to **switch to the target branch** first, using `git checkout`. Then, you can use `git merge` to **merge the source branch into the target branch**.
```shell
# Syntax:
# git checkout <target-branch>
# git merge <source-branch>
git checkout ... | [Merging a branch]
## Merging a branch
In order to merge a branch, you want to **switch to the target branch** first, using `git checkout`. Then, you can use `git merge` to **merge the source branch into the target branch**.
```shell
# Syntax:
# git checkout <target-branch>
# git merge <source-branch>
git checkout ... | code_snippets | ||
cdc9121c-5bc0-4bbc-bbdc-713a2346b183 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/merge-branch-merge-commit.md | unknown | 9c935ce4-050c-4f0d-816e-6e48b05016b1 | 0 | SemanticChunker@1.0.0 | 6a4a752981fdcfe2714ec41f3a23c1d326f3f776b7acbb6fa35f73dd5e6abc9b | ---
title: Merge a branch in Git
shortTitle: Merge branch
language: git
tags: [repository,branch]
cover: meteora
excerpt: Learn how to merge a branch in Git with or without creating a merge commit, depending on your team's workflow.
listed: true
dateModified: 2023-05-26
---
Branches are Git's way to organize separate ... | unknown | unknown | ---
title: Merge a branch in Git
shortTitle: Merge branch
language: git
tags: [repository,branch]
cover: meteora
excerpt: Learn how to merge a branch in Git with or without creating a merge commit, depending on your team's workflow.
listed: true
dateModified: 2023-05-26
---
Branches are Git's way to organize separate ... | ---
title: Merge a branch in Git
shortTitle: Merge branch
language: git
tags: [repository,branch]
cover: meteora
excerpt: Learn how to merge a branch in Git with or without creating a merge commit, depending on your team's workflow.
listed: true
dateModified: 2023-05-26
---
Branches are Git's way to organize separate ... | code_snippets | ||
0c781114-c7a2-41c1-a0e8-87e9cd267cd2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/move-commits-to-branch.md | unknown | 05ad87da-2cff-4cb8-83bc-36688e75bd86 | 0 | SemanticChunker@1.0.0 | c890ee2696f917d157ebf5ea86a21c0ff27251fbc1bedac4c9e7891d71b05180 | ---
title: Move Git commits from master to a new branch
shortTitle: Move commits from master to branch
language: git
tags: [branch,repository]
cover: red-succulent
excerpt: Did you accidentally commit to `master` instead of a feature branch? Here's how you can move those commits to a new branch.
listed: true
dateModifi... | unknown | unknown | ---
title: Move Git commits from master to a new branch
shortTitle: Move commits from master to branch
language: git
tags: [branch,repository]
cover: red-succulent
excerpt: Did you accidentally commit to `master` instead of a feature branch? Here's how you can move those commits to a new branch.
listed: true
dateModifi... | ---
title: Move Git commits from master to a new branch
shortTitle: Move commits from master to branch
language: git
tags: [branch,repository]
cover: red-succulent
excerpt: Did you accidentally commit to `master` instead of a feature branch? Here's how you can move those commits to a new branch.
listed: true
dateModifi... | code_snippets | ||
6ac55ced-a268-4f9a-803a-b570208344f2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/push-pull-changes.md | unknown | c332efc3-8bcb-4762-b799-6d4d1ba47f67 | 1 | SemanticChunker@1.0.0 | ebaa51eb48b0bf038d3b0eae0391be71caad5d7a339e7765978a0977fa6ca43f | [Push changes to remote]
## Push changes to remote
In order to push changes to the remote repository, you'll first have to set up a remote tracking branch. This is often done by using `git branch` with the `-u` flag. Then, you can use `git push` to push the latest changes from the local branch to the remote.
```shel... | unknown | unknown | [Push changes to remote]
## Push changes to remote
In order to push changes to the remote repository, you'll first have to set up a remote tracking branch. This is often done by using `git branch` with the `-u` flag. Then, you can use `git push` to push the latest changes from the local branch to the remote.
```shel... | [Push changes to remote]
## Push changes to remote
In order to push changes to the remote repository, you'll first have to set up a remote tracking branch. This is often done by using `git branch` with the `-u` flag. Then, you can use `git push` to push the latest changes from the local branch to the remote.
```shel... | code_snippets | ||
8697c932-03ad-47e0-aa6f-304a972f85b2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/push-pull-changes.md | unknown | c332efc3-8bcb-4762-b799-6d4d1ba47f67 | 0 | SemanticChunker@1.0.0 | 4198e82bea3a4bed33eb1b45c259c22f81a48ba461cfe42cc178e955157c3565 | ---
title: Git Basics - Push and pull changes between local and remote
shortTitle: Push and pull changes
language: git
tags: [repository,branch]
cover: orange-coffee-2
excerpt: Learn how to push and pull changes between local and remote repositories.
listed: true
dateModified: 2023-06-01
---
One of the main benefits o... | unknown | unknown | ---
title: Git Basics - Push and pull changes between local and remote
shortTitle: Push and pull changes
language: git
tags: [repository,branch]
cover: orange-coffee-2
excerpt: Learn how to push and pull changes between local and remote repositories.
listed: true
dateModified: 2023-06-01
---
One of the main benefits o... | ---
title: Git Basics - Push and pull changes between local and remote
shortTitle: Push and pull changes
language: git
tags: [repository,branch]
cover: orange-coffee-2
excerpt: Learn how to push and pull changes between local and remote repositories.
listed: true
dateModified: 2023-06-01
---
One of the main benefits o... | code_snippets | ||
e2402b47-3a1b-4130-b315-d5291705625d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/push-pull-changes.md | unknown | c332efc3-8bcb-4762-b799-6d4d1ba47f67 | 2 | SemanticChunker@1.0.0 | 5622bfe5913b1f47fa3cb6b8a35ff8588033bfac12c994f37f6e2f98b9c80a74 | [Push changes to remote > Pull changes from remote]
## Pull changes from remote
Similar to pushing changes to a remote repository, you'll have to set up a remote tracking branch before you can pull changes from it. Luckily, `git checkout` is smart enough to do this for you, provided there is no local branch with the ... | unknown | unknown | [Push changes to remote > Pull changes from remote]
## Pull changes from remote
Similar to pushing changes to a remote repository, you'll have to set up a remote tracking branch before you can pull changes from it. Luckily, `git checkout` is smart enough to do this for you, provided there is no local branch with the ... | [Push changes to remote > Pull changes from remote]
## Pull changes from remote
Similar to pushing changes to a remote repository, you'll have to set up a remote tracking branch before you can pull changes from it. Luckily, `git checkout` is smart enough to do this for you, provided there is no local branch with the ... | code_snippets | ||
40e12f95-6ad0-416d-8dc3-49b44f1b8395 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/list-aliases.md | unknown | 1c18e8aa-7154-4d6d-9e8e-8ad66af2d35c | 0 | SemanticChunker@1.0.0 | d234a28044228cc2ca9be197db2f1a2ba12b7ffaffb46b1672df5d88e0279448 | ---
title: List all Git aliases
shortTitle: List aliases
language: git
tags: [configuration]
cover: coffee-float
excerpt: Did you set up a lot of Git aliases and forgot what they are? List them all with this command.
listed: true
dateModified: 2026-01-07
---
Setting up Git aliases can be a great way to save time and m... | unknown | unknown | ---
title: List all Git aliases
shortTitle: List aliases
language: git
tags: [configuration]
cover: coffee-float
excerpt: Did you set up a lot of Git aliases and forgot what they are? List them all with this command.
listed: true
dateModified: 2026-01-07
---
Setting up Git aliases can be a great way to save time and m... | ---
title: List all Git aliases
shortTitle: List aliases
language: git
tags: [configuration]
cover: coffee-float
excerpt: Did you set up a lot of Git aliases and forgot what they are? List them all with this command.
listed: true
dateModified: 2026-01-07
---
Setting up Git aliases can be a great way to save time and m... | code_snippets | ||
7adf1616-01da-4b3a-9066-3be65b8befc1 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/line-endings.md | unknown | 0fc408aa-6f5e-46f8-a2ff-13d29088eb94 | 0 | SemanticChunker@1.0.0 | 42e996f9c9251af615050981fec47d52d4c3c5a6f6c8c2abc961a9d493431125 | ---
title: Configure Git's line endings
shortTitle: Configure line endings
language: git
tags: [repository,configuration]
cover: leaves-read
excerpt: If you're working with a team using different operating systems, configuring line endings can help maintain consistency.
listed: true
dateModified: 2024-04-13
---
If you... | unknown | unknown | ---
title: Configure Git's line endings
shortTitle: Configure line endings
language: git
tags: [repository,configuration]
cover: leaves-read
excerpt: If you're working with a team using different operating systems, configuring line endings can help maintain consistency.
listed: true
dateModified: 2024-04-13
---
If you... | ---
title: Configure Git's line endings
shortTitle: Configure line endings
language: git
tags: [repository,configuration]
cover: leaves-read
excerpt: If you're working with a team using different operating systems, configuring line endings can help maintain consistency.
listed: true
dateModified: 2024-04-13
---
If you... | code_snippets | ||
4bd62be3-8ff2-4fd0-808b-c6eea8870802 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/interactive-rebase.md | unknown | f2f07c31-a480-4214-a618-69aa4cd46d6f | 1 | SemanticChunker@1.0.0 | 94cc9e36fe94e787641c73a9d7f06f97a61cce4ea3e548f53ddd760cc5cc0b55 | [Perform an interactive rebase]
## Perform an interactive rebase
Simply using `git rebase -i <commit>` will **open an editor** with a list of commits and actions to perform for each one. You can reorder the commits, squash them together, edit commit messages, and more.
> [!TIP]
>
> If you want to learn how to [confi... | unknown | unknown | [Perform an interactive rebase]
## Perform an interactive rebase
Simply using `git rebase -i <commit>` will **open an editor** with a list of commits and actions to perform for each one. You can reorder the commits, squash them together, edit commit messages, and more.
> [!TIP]
>
> If you want to learn how to [confi... | [Perform an interactive rebase]
## Perform an interactive rebase
Simply using `git rebase -i <commit>` will **open an editor** with a list of commits and actions to perform for each one. You can reorder the commits, squash them together, edit commit messages, and more.
> [!TIP]
>
> If you want to learn how to [confi... | code_snippets | ||
65b2f47f-f4f6-4d8a-b8a2-4a921c2ad546 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/interactive-rebase.md | unknown | f2f07c31-a480-4214-a618-69aa4cd46d6f | 0 | SemanticChunker@1.0.0 | f9cd520ffb80ec456ff52945fdc728d0f4bffb770ad000158ef54dbe43d133eb | ---
title: Perform an interactive rebase in Git
shortTitle: Interactive rebase
language: git
tags: [branch]
cover: tea-laptop-table
excerpt: Reorder, squash, and edit commits interactively using Git's interactive rebase feature.
listed: true
dateModified: 2024-05-02
---
If you want to **rewrite the commit history of a... | unknown | unknown | ---
title: Perform an interactive rebase in Git
shortTitle: Interactive rebase
language: git
tags: [branch]
cover: tea-laptop-table
excerpt: Reorder, squash, and edit commits interactively using Git's interactive rebase feature.
listed: true
dateModified: 2024-05-02
---
If you want to **rewrite the commit history of a... | ---
title: Perform an interactive rebase in Git
shortTitle: Interactive rebase
language: git
tags: [branch]
cover: tea-laptop-table
excerpt: Reorder, squash, and edit commits interactively using Git's interactive rebase feature.
listed: true
dateModified: 2024-05-02
---
If you want to **rewrite the commit history of a... | code_snippets | ||
a914667f-0e53-4796-8b8d-7bb0c4fdf37b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/interactive-rebase.md | unknown | f2f07c31-a480-4214-a618-69aa4cd46d6f | 2 | SemanticChunker@1.0.0 | c4cd5db8d84aaa910cacb52cccd298ad2b8eb4f1fa0fcac28fdf5ba9f427d097 | [Perform an interactive rebase > Interactive rebase actions]
## Interactive rebase actions
The options that are available to you during an interactive rebase are multiple, but the ones that are **most often used** are the following:
- `p`, `pick`: Use the commit as is.
- `r`, `reword`: Use the commit, but edit the c... | unknown | unknown | [Perform an interactive rebase > Interactive rebase actions]
## Interactive rebase actions
The options that are available to you during an interactive rebase are multiple, but the ones that are **most often used** are the following:
- `p`, `pick`: Use the commit as is.
- `r`, `reword`: Use the commit, but edit the c... | [Perform an interactive rebase > Interactive rebase actions]
## Interactive rebase actions
The options that are available to you during an interactive rebase are multiple, but the ones that are **most often used** are the following:
- `p`, `pick`: Use the commit as is.
- `r`, `reword`: Use the commit, but edit the c... | code_snippets | ||
3c7b80d6-d2e8-4899-9d1b-447d23690ffd | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/github-co-authors.md | unknown | c116fd48-88aa-493d-a246-98fa7eee2754 | 1 | SemanticChunker@1.0.0 | 72ecef823d3be3ca30901bc9b97db2ed005c8d8e902af3c4ef6360ba07c05c88 | [Notes]
## Notes
- To correctly attribute a commit to a co-author, you must use the email associated with their GitHub account.
- If a person's email is private, you can use their GitHub-provided `no-reply` email.
- Leave one or preferably two empty lines before any `Co-authored-by` trailers. | unknown | unknown | [Notes]
## Notes
- To correctly attribute a commit to a co-author, you must use the email associated with their GitHub account.
- If a person's email is private, you can use their GitHub-provided `no-reply` email.
- Leave one or preferably two empty lines before any `Co-authored-by` trailers. | [Notes]
## Notes
- To correctly attribute a commit to a co-author, you must use the email associated with their GitHub account.
- If a person's email is private, you can use their GitHub-provided `no-reply` email.
- Leave one or preferably two empty lines before any `Co-authored-by` trailers. | code_snippets | ||
98513852-298c-4b9d-bff7-49bfcfa1764f | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/github-co-authors.md | unknown | c116fd48-88aa-493d-a246-98fa7eee2754 | 0 | SemanticChunker@1.0.0 | 7dc59d7efa1c729cdd2b126f07b62fcb2fa223be59672a4c4b8154a910669b95 | ---
title: How to add multiple authors to a commit
shortTitle: Add multiple authors to a commit
language: git
tags: [github,programming,webdev]
cover: book-chair
excerpt: Learn how to add multiple authors to a git commit with this quick and easy tip.
listed: true
tocEnabled: false
dateModified: 2021-06-12
---
You can ... | unknown | unknown | ---
title: How to add multiple authors to a commit
shortTitle: Add multiple authors to a commit
language: git
tags: [github,programming,webdev]
cover: book-chair
excerpt: Learn how to add multiple authors to a git commit with this quick and easy tip.
listed: true
tocEnabled: false
dateModified: 2021-06-12
---
You can ... | ---
title: How to add multiple authors to a commit
shortTitle: Add multiple authors to a commit
language: git
tags: [github,programming,webdev]
cover: book-chair
excerpt: Learn how to add multiple authors to a git commit with this quick and easy tip.
listed: true
tocEnabled: false
dateModified: 2021-06-12
---
You can ... | code_snippets | ||
aaea86f3-f9b4-4de1-b42f-ea2d2ab8958c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/purge-file.md | unknown | 5188a24d-6b2b-4f6b-9c78-adadae1e1f68 | 0 | SemanticChunker@1.0.0 | e7214002bcd70309be8a10e930884e90017d6dc42fc6b1a69f383a971c2c03c7 | ---
title: Purge a file from Git history
shortTitle: Purge file
language: git
tags: [repository,remote]
cover: white-flower
excerpt: Did you accidentally commit sensitive information? Learn how to completely purge a file from Git history.
listed: true
dateModified: 2024-05-01
---
If you've ever **accidentally committe... | unknown | unknown | ---
title: Purge a file from Git history
shortTitle: Purge file
language: git
tags: [repository,remote]
cover: white-flower
excerpt: Did you accidentally commit sensitive information? Learn how to completely purge a file from Git history.
listed: true
dateModified: 2024-05-01
---
If you've ever **accidentally committe... | ---
title: Purge a file from Git history
shortTitle: Purge file
language: git
tags: [repository,remote]
cover: white-flower
excerpt: Did you accidentally commit sensitive information? Learn how to completely purge a file from Git history.
listed: true
dateModified: 2024-05-01
---
If you've ever **accidentally committe... | code_snippets | ||
ccf73943-bd3b-4119-9f20-7d1928632f21 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/purge-file.md | unknown | 5188a24d-6b2b-4f6b-9c78-adadae1e1f68 | 1 | SemanticChunker@1.0.0 | f3519c8194753db06f851fb7be9a4a007a610aac85f02d467d91520739b33954 | ```shell
# Syntax:
# git filter-branch --force --index-filter \
# "git rm --cached --ignore-unmatch <path>" \
# --prune-empty --tag-name-filter cat -- --all
# git push <remote> --force --all
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch config/apiKeys.json" \
--prune-empty --tag-name-f... | unknown | unknown | ```shell
# Syntax:
# git filter-branch --force --index-filter \
# "git rm --cached --ignore-unmatch <path>" \
# --prune-empty --tag-name-filter cat -- --all
# git push <remote> --force --all
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch config/apiKeys.json" \
--prune-empty --tag-name-f... | ```shell
# Syntax:
# git filter-branch --force --index-filter \
# "git rm --cached --ignore-unmatch <path>" \
# --prune-empty --tag-name-filter cat -- --all
# git push <remote> --force --all
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch config/apiKeys.json" \
--prune-empty --tag-name-f... | code_snippets | ||
a9f65567-fe93-487d-8c72-5bdaa48d8e6c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/sort-branches-by-date.md | unknown | 61005d10-1ca7-4fc6-89fe-c30a4b384552 | 0 | SemanticChunker@1.0.0 | a9398b315c19383bf457e8bf00dffdccc2f5053087a01a2a1e8ea63113e13e08 | ---
title: View Git branches sorted by date
shortTitle: Sort branches by date
language: git
tags: [repository,branch]
cover: sea-view
excerpt: Do you want to see a list of all local branches sorted by date? Here's a simple command to help you with that.
listed: true
dateModified: 2024-04-01
---
Have you ever wanted to... | unknown | unknown | ---
title: View Git branches sorted by date
shortTitle: Sort branches by date
language: git
tags: [repository,branch]
cover: sea-view
excerpt: Do you want to see a list of all local branches sorted by date? Here's a simple command to help you with that.
listed: true
dateModified: 2024-04-01
---
Have you ever wanted to... | ---
title: View Git branches sorted by date
shortTitle: Sort branches by date
language: git
tags: [repository,branch]
cover: sea-view
excerpt: Do you want to see a list of all local branches sorted by date? Here's a simple command to help you with that.
listed: true
dateModified: 2024-04-01
---
Have you ever wanted to... | code_snippets | ||
bd4e7fe4-d133-40c9-bc5e-126fecaafd46 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/restore-deleted-file.md | unknown | eabf42ce-edf3-40de-a719-73a214c2a842 | 0 | SemanticChunker@1.0.0 | b03f72ecc2eb7b070c6f9d2febe14d7525d57edebc667b97b989459b7d2ada3e | ---
title: Restore deleted files in a Git commit
shortTitle: Restore deleted file
language: git
tags: [branch]
cover: succulent-red-light
excerpt: Have you accidentally deleted a file? Or maybe you need to restore a file that was deleted? Here's how Git can help you.
listed: true
dateModified: 2024-04-22
---
Have you ... | unknown | unknown | ---
title: Restore deleted files in a Git commit
shortTitle: Restore deleted file
language: git
tags: [branch]
cover: succulent-red-light
excerpt: Have you accidentally deleted a file? Or maybe you need to restore a file that was deleted? Here's how Git can help you.
listed: true
dateModified: 2024-04-22
---
Have you ... | ---
title: Restore deleted files in a Git commit
shortTitle: Restore deleted file
language: git
tags: [branch]
cover: succulent-red-light
excerpt: Have you accidentally deleted a file? Or maybe you need to restore a file that was deleted? Here's how Git can help you.
listed: true
dateModified: 2024-04-22
---
Have you ... | code_snippets | ||
96dfa040-fe5f-4c66-8a4d-cfdd2dd52ff4 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/set-or-amend-commit-author.md | unknown | 2dd52681-92e5-417d-bd3e-5d8f6329045b | 3 | SemanticChunker@1.0.0 | a8b3a68f147ba6a47ffcb93fc38f53bf7091a6ec5d1f34c2323b3b9797771cc3 | [Create a commit by a different author > Caveats]
## Caveats
Changing the author of a commit will also change its **SHA-1 checksum**. If you've already pushed the commit to a remote repository, you will need to force push the updated commit to the remote.
Additionally, if your remote repository is configured to only... | unknown | unknown | [Create a commit by a different author > Caveats]
## Caveats
Changing the author of a commit will also change its **SHA-1 checksum**. If you've already pushed the commit to a remote repository, you will need to force push the updated commit to the remote.
Additionally, if your remote repository is configured to only... | [Create a commit by a different author > Caveats]
## Caveats
Changing the author of a commit will also change its **SHA-1 checksum**. If you've already pushed the commit to a remote repository, you will need to force push the updated commit to the remote.
Additionally, if your remote repository is configured to only... | code_snippets | ||
99d429b7-c27d-4288-9390-a53d3bf1e5f6 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/set-or-amend-commit-author.md | unknown | 2dd52681-92e5-417d-bd3e-5d8f6329045b | 0 | SemanticChunker@1.0.0 | 46f574548b180933fddea8e0f40e29f21b24dd4bbba873d5eaadb323334298a2 | ---
title: Create a commit by a different author in Git
shortTitle: Set or amend commit author
language: git
tags: [commit]
cover: new-plant
excerpt: Ever wanted to commit as someone else? Maybe change the author of an existing commit? Here's how.
listed: true
dateModified: 2023-05-24
---
Every Git commit is associate... | unknown | unknown | ---
title: Create a commit by a different author in Git
shortTitle: Set or amend commit author
language: git
tags: [commit]
cover: new-plant
excerpt: Ever wanted to commit as someone else? Maybe change the author of an existing commit? Here's how.
listed: true
dateModified: 2023-05-24
---
Every Git commit is associate... | ---
title: Create a commit by a different author in Git
shortTitle: Set or amend commit author
language: git
tags: [commit]
cover: new-plant
excerpt: Ever wanted to commit as someone else? Maybe change the author of an existing commit? Here's how.
listed: true
dateModified: 2023-05-24
---
Every Git commit is associate... | code_snippets | ||
9ade1cf1-6730-4e47-a337-ee500ca3a22e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/set-or-amend-commit-author.md | unknown | 2dd52681-92e5-417d-bd3e-5d8f6329045b | 2 | SemanticChunker@1.0.0 | da45ea1ba6c57c40bb0c311c7056e8b41fe8251e5d067ec646156578140129f0 | [Create a commit by a different author > Change the last commit's author]
## Change the last commit's author
In case you want to **change the author of the last commit**, you only need to add the `--amend` flag to the previous command. You can learn more about updating commits in [our guide on amending commits](/git/... | unknown | unknown | [Create a commit by a different author > Change the last commit's author]
## Change the last commit's author
In case you want to **change the author of the last commit**, you only need to add the `--amend` flag to the previous command. You can learn more about updating commits in [our guide on amending commits](/git/... | [Create a commit by a different author > Change the last commit's author]
## Change the last commit's author
In case you want to **change the author of the last commit**, you only need to add the `--amend` flag to the previous command. You can learn more about updating commits in [our guide on amending commits](/git/... | code_snippets | ||
c056e539-300b-4f18-85bb-be9960216d9e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/set-or-amend-commit-author.md | unknown | 2dd52681-92e5-417d-bd3e-5d8f6329045b | 1 | SemanticChunker@1.0.0 | 07f287a8b67a69c7be715f927389abc1173b1f3fb3b3193dfdbb2b40e63cc043 | [Create a commit by a different author]
## Create a commit by a different author
As long as you have the author's information, you can create a commit by them. Using the `--author` option for `git commit` will allow you to **create a new commit by a different author**.
```shell
# Syntax: git commit --author="<name> ... | unknown | unknown | [Create a commit by a different author]
## Create a commit by a different author
As long as you have the author's information, you can create a commit by them. Using the `--author` option for `git commit` will allow you to **create a new commit by a different author**.
```shell
# Syntax: git commit --author="<name> ... | [Create a commit by a different author]
## Create a commit by a different author
As long as you have the author's information, you can create a commit by them. Using the `--author` option for `git commit` will allow you to **create a new commit by a different author**.
```shell
# Syntax: git commit --author="<name> ... | code_snippets | ||
d1af93f1-3dd2-470a-a200-88f9a6415834 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/set-default-push-branch.md | unknown | 0e6a58de-2f46-47f6-b990-b8e25dbb8cd7 | 0 | SemanticChunker@1.0.0 | 10aaf43df0151d06a442c363c6ac1f4b80a9b5738ec8dab3f06571127f9a0fc3 | ---
title: Set the default push branch name in Git
shortTitle: Set default push branch
language: git
tags: [configuration,branch]
cover: pink-flower
excerpt: Tired of manually specifying the remote branch name when pushing? Configure Git to use the current branch name as the default.
listed: true
dateModified: 2024-05-... | unknown | unknown | ---
title: Set the default push branch name in Git
shortTitle: Set default push branch
language: git
tags: [configuration,branch]
cover: pink-flower
excerpt: Tired of manually specifying the remote branch name when pushing? Configure Git to use the current branch name as the default.
listed: true
dateModified: 2024-05-... | ---
title: Set the default push branch name in Git
shortTitle: Set default push branch
language: git
tags: [configuration,branch]
cover: pink-flower
excerpt: Tired of manually specifying the remote branch name when pushing? Configure Git to use the current branch name as the default.
listed: true
dateModified: 2024-05-... | code_snippets | ||
aabada8d-9311-41dd-88f4-3d9455993ebf | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/split-commit.md | unknown | 88e9c5e1-7bf4-4886-87d0-d81403b32cf9 | 0 | SemanticChunker@1.0.0 | efbc2cef68493bfde57d38ec40a40e30bd40efc8deabbed7564b0794c3832d57 | ---
title: Split a Git commit into multiple commits
shortTitle: Split commit
language: git
tags: [commit,branch]
cover: interior-16
excerpt: Altering Git history to split a commit sounds intimidating, but it's not that hard. Let's walk through the process step by step.
listed: true
dateModified: 2024-05-05
---
I've of... | unknown | unknown | ---
title: Split a Git commit into multiple commits
shortTitle: Split commit
language: git
tags: [commit,branch]
cover: interior-16
excerpt: Altering Git history to split a commit sounds intimidating, but it's not that hard. Let's walk through the process step by step.
listed: true
dateModified: 2024-05-05
---
I've of... | ---
title: Split a Git commit into multiple commits
shortTitle: Split commit
language: git
tags: [commit,branch]
cover: interior-16
excerpt: Altering Git history to split a commit sounds intimidating, but it's not that hard. Let's walk through the process step by step.
listed: true
dateModified: 2024-05-05
---
I've of... | code_snippets | ||
e952bf78-8025-4b64-b118-f721a65a3968 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/split-commit.md | unknown | 88e9c5e1-7bf4-4886-87d0-d81403b32cf9 | 1 | SemanticChunker@1.0.0 | c08d6e25efc3b7338a7031e492c6ddb8fbcd35807ebfcf8fab0b2d82bcb5a466 | [3. Save and close the editor to start the rebase]
# 3. Save and close the editor to start the rebase
```
```shell
# Stopped at 3050fc0... Fix network bug
# You can amend the commit now, with
#
# git commit --amend
#
# Once you are satisfied with your changes, run
#
# git rebase --continue
# 4. Use `git reset HEAD^... | unknown | unknown | [3. Save and close the editor to start the rebase]
# 3. Save and close the editor to start the rebase
```
```shell
# Stopped at 3050fc0... Fix network bug
# You can amend the commit now, with
#
# git commit --amend
#
# Once you are satisfied with your changes, run
#
# git rebase --continue
# 4. Use `git reset HEAD^... | [3. Save and close the editor to start the rebase]
# 3. Save and close the editor to start the rebase
```
```shell
# Stopped at 3050fc0... Fix network bug
# You can amend the commit now, with
#
# git commit --amend
#
# Once you are satisfied with your changes, run
#
# git rebase --continue
# 4. Use `git reset HEAD^... | code_snippets | ||
27b1e730-9f51-4328-ad58-d6865b7029d2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/reset-master.md | unknown | 77520a93-1cf0-467c-ba0c-9afaa2d703bc | 0 | SemanticChunker@1.0.0 | 85997e5f46afad0c8946593d801438523a4efb9622cffe39900aa2a7d4e1f31e | ---
title: Reset your local master branch to match remote
shortTitle: Reset master to match remote
language: git
tags: [repository,branch]
cover: old-consoles
excerpt: Learn how to quickly and easily reset your local `master` branch to match the one on the remote.
listed: true
dateModified: 2024-03-31
---
If you've ev... | unknown | unknown | ---
title: Reset your local master branch to match remote
shortTitle: Reset master to match remote
language: git
tags: [repository,branch]
cover: old-consoles
excerpt: Learn how to quickly and easily reset your local `master` branch to match the one on the remote.
listed: true
dateModified: 2024-03-31
---
If you've ev... | ---
title: Reset your local master branch to match remote
shortTitle: Reset master to match remote
language: git
tags: [repository,branch]
cover: old-consoles
excerpt: Learn how to quickly and easily reset your local `master` branch to match the one on the remote.
listed: true
dateModified: 2024-03-31
---
If you've ev... | code_snippets | ||
08f0acfd-cd9e-4fcf-9f5f-8c0f649bbcd5 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/rewind-to-commit.md | unknown | f56b3407-b5ad-46c3-b3fe-a51c018d37bb | 3 | SemanticChunker@1.0.0 | 32227d8d9b77070b2ae0fa63f8d09d6386ad7834e155a8105f5aaba0a0b22c5b | [Rewind to a commit > Notes]
## Notes
The `--hard` flag is considered a destructive action, which means you should be extra careful when using it. If things go wrong, you might be able to recover your changes by [viewing the reference log](/git/s/view-undo-history).
In case you've already pushed some changes to a re... | unknown | unknown | [Rewind to a commit > Notes]
## Notes
The `--hard` flag is considered a destructive action, which means you should be extra careful when using it. If things go wrong, you might be able to recover your changes by [viewing the reference log](/git/s/view-undo-history).
In case you've already pushed some changes to a re... | [Rewind to a commit > Notes]
## Notes
The `--hard` flag is considered a destructive action, which means you should be extra careful when using it. If things go wrong, you might be able to recover your changes by [viewing the reference log](/git/s/view-undo-history).
In case you've already pushed some changes to a re... | code_snippets | ||
63377e89-86e9-441a-9bd2-76cfdb7bffeb | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/rewind-to-commit.md | unknown | f56b3407-b5ad-46c3-b3fe-a51c018d37bb | 2 | SemanticChunker@1.0.0 | 8e1b9563f02035abd631521de9fab6f53c9fb41403dad5ad0d68648bb6ec29c5 | [Rewind to a commit > Rewind back n commits]
## Rewind back n commits
You can also use `git reset` to rewind back a **given number of commits**. To do so, you can use the `HEAD~<n>` syntax, where `<n>` is the number of commits you want to rewind back.
```shell
# Syntax: git reset [--hard] HEAD~<n>
git reset HEAD~5
... | unknown | unknown | [Rewind to a commit > Rewind back n commits]
## Rewind back n commits
You can also use `git reset` to rewind back a **given number of commits**. To do so, you can use the `HEAD~<n>` syntax, where `<n>` is the number of commits you want to rewind back.
```shell
# Syntax: git reset [--hard] HEAD~<n>
git reset HEAD~5
... | [Rewind to a commit > Rewind back n commits]
## Rewind back n commits
You can also use `git reset` to rewind back a **given number of commits**. To do so, you can use the `HEAD~<n>` syntax, where `<n>` is the number of commits you want to rewind back.
```shell
# Syntax: git reset [--hard] HEAD~<n>
git reset HEAD~5
... | code_snippets | ||
65c27a8a-5f42-4c19-91b3-ebe7ba44730f | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/rewind-to-commit.md | unknown | f56b3407-b5ad-46c3-b3fe-a51c018d37bb | 1 | SemanticChunker@1.0.0 | c94a688db2a1942653c0f75bbfc1f6f856509ef918d5501cafa582a14a1915d1 | [Rewind to a commit]
## Rewind to a commit
To rewind back to a specific commit, you can use `git reset`. This command will **uncommit and unstage changes**, but leave them in the working directory. You can use the `--hard` flag to **uncommit, unstage and delete** changes instead.
```shell
# Syntax: git reset [--hard... | unknown | unknown | [Rewind to a commit]
## Rewind to a commit
To rewind back to a specific commit, you can use `git reset`. This command will **uncommit and unstage changes**, but leave them in the working directory. You can use the `--hard` flag to **uncommit, unstage and delete** changes instead.
```shell
# Syntax: git reset [--hard... | [Rewind to a commit]
## Rewind to a commit
To rewind back to a specific commit, you can use `git reset`. This command will **uncommit and unstage changes**, but leave them in the working directory. You can use the `--hard` flag to **uncommit, unstage and delete** changes instead.
```shell
# Syntax: git reset [--hard... | code_snippets | ||
9779fe46-1b4b-4f57-9faf-1e130d921c7f | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/rewind-to-commit.md | unknown | f56b3407-b5ad-46c3-b3fe-a51c018d37bb | 0 | SemanticChunker@1.0.0 | f2e9bc4b5fe93891cad5e79230a589a937861082b7f9f19cb49c38b6202a7826 | ---
title: Rewind back to a specific commit in Git
shortTitle: Rewind to commit
language: git
tags: [branch,commit]
cover: walking
excerpt: Did you make a mistake but haven't pushed your changes yet? Learn how to rewind back to a specific commit in Git.
listed: true
dateModified: 2023-05-26
---
One of Git's greatest s... | unknown | unknown | ---
title: Rewind back to a specific commit in Git
shortTitle: Rewind to commit
language: git
tags: [branch,commit]
cover: walking
excerpt: Did you make a mistake but haven't pushed your changes yet? Learn how to rewind back to a specific commit in Git.
listed: true
dateModified: 2023-05-26
---
One of Git's greatest s... | ---
title: Rewind back to a specific commit in Git
shortTitle: Rewind to commit
language: git
tags: [branch,commit]
cover: walking
excerpt: Did you make a mistake but haven't pushed your changes yet? Learn how to rewind back to a specific commit in Git.
listed: true
dateModified: 2023-05-26
---
One of Git's greatest s... | code_snippets | ||
15b13780-06be-4e7f-8a91-294d733e5c98 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/rename-branch.md | unknown | ab5bf8ad-a098-4ebc-85d6-87041678408f | 2 | SemanticChunker@1.0.0 | 4f79cc30391709017579b94b6bc5225cfbcb36e6efac171a1e79a5d6a83b2745 | [Rename local branch > Rename remote branch]
## Rename remote branch
In order to rename a remote branch, you have to use `git push origin --delete <old-name>` to **delete the old remote branch**. Then, you can use `git push origin -u <new-name>` to set `<new-name>` as the remote branch for the renamed branch.
```she... | unknown | unknown | [Rename local branch > Rename remote branch]
## Rename remote branch
In order to rename a remote branch, you have to use `git push origin --delete <old-name>` to **delete the old remote branch**. Then, you can use `git push origin -u <new-name>` to set `<new-name>` as the remote branch for the renamed branch.
```she... | [Rename local branch > Rename remote branch]
## Rename remote branch
In order to rename a remote branch, you have to use `git push origin --delete <old-name>` to **delete the old remote branch**. Then, you can use `git push origin -u <new-name>` to set `<new-name>` as the remote branch for the renamed branch.
```she... | code_snippets | ||
292ab2d1-3301-4c98-8a25-11f3a3d15e7e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/git/s/rename-branch.md | unknown | ab5bf8ad-a098-4ebc-85d6-87041678408f | 0 | SemanticChunker@1.0.0 | b2f7c091c7e5398c10287cff62bb8a9e6403bf6988dfe64fd9a099a424daeb9e | ---
title: Rename a local or remote Git branch
shortTitle: Rename branch
language: git
tags: [branch]
cover: horse-sunset
excerpt: Made a mistake with your branch name? Learn how to rename a local or remote Git branch.
listed: true
dateModified: 2024-04-08
---
Have you ever made a mistake when naming a branch? Or mayb... | unknown | unknown | ---
title: Rename a local or remote Git branch
shortTitle: Rename branch
language: git
tags: [branch]
cover: horse-sunset
excerpt: Made a mistake with your branch name? Learn how to rename a local or remote Git branch.
listed: true
dateModified: 2024-04-08
---
Have you ever made a mistake when naming a branch? Or mayb... | ---
title: Rename a local or remote Git branch
shortTitle: Rename branch
language: git
tags: [branch]
cover: horse-sunset
excerpt: Made a mistake with your branch name? Learn how to rename a local or remote Git branch.
listed: true
dateModified: 2024-04-08
---
Have you ever made a mistake when naming a branch? Or mayb... | code_snippets |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.