mirror of
https://codeberg.org/Mo8it/How_To_Linux.git
synced 2024-12-05 01:40:32 +00:00
Compare commits
11 commits
98cfbeaf60
...
033d0996c0
Author | SHA1 | Date | |
---|---|---|---|
|
033d0996c0 | ||
|
697d211a76 | ||
|
6f877f5918 | ||
|
6d5c0d9862 | ||
|
11a9e65a43 | ||
|
39c5f1d7cf | ||
|
9a0b90063c | ||
|
9d7ac6647c | ||
|
a54733de56 | ||
|
8e46045b01 | ||
|
a3d2250b65 |
1 changed files with 81 additions and 0 deletions
|
@ -58,6 +58,22 @@ git commit -m "Your commit message here"
|
|||
|
||||
## git checkout
|
||||
|
||||
This command enables you to switch to another branch or to another commit.
|
||||
|
||||
Examples are:
|
||||
|
||||
```bash
|
||||
git checkout "branchname"
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
git checkout -b "branchname"
|
||||
```
|
||||
|
||||
If you want to create a new branch and switch to it.
|
||||
|
||||
## git push
|
||||
|
||||
## git pull
|
||||
|
@ -66,12 +82,77 @@ git commit -m "Your commit message here"
|
|||
|
||||
## git merge
|
||||
|
||||
This command is used to combine two branches together. Use git checkout to visit the branch you want to merge to.
|
||||
|
||||
```bash
|
||||
$ git checkout main
|
||||
$ git merge branch2
|
||||
```
|
||||
|
||||
This will merge the branch "branch2" into the branch, where this command was executed in.(Here: "main")
|
||||
|
||||
## git reset
|
||||
|
||||
## git revert
|
||||
|
||||
|
||||
## git cherry-pick
|
||||
|
||||
### Description
|
||||
|
||||
The `git cherry-pick` command applies a specific commit from one branch to another. This can be useful for undoing changes, applying bug fixes to a different branch, or picking out specific changes from a merge commit.
|
||||
|
||||
### Usage
|
||||
|
||||
The basic syntax for the `git cherry-pick` command is:
|
||||
|
||||
```bash
|
||||
git cherry-pick <commit-hash>
|
||||
```
|
||||
where `<commit-hash>` is the SHA-1 hash of the commit you want to cherry-pick. You can also use the `-n` option to preview the changes without actually applying them.
|
||||
|
||||
For example, to cherry-pick the commit with the SHA-1 hash `1234567890abcdef`, you would run the following command:
|
||||
|
||||
```bash
|
||||
git cherry-pick 1234567890abcdef
|
||||
```
|
||||
|
||||
Example with visualization of the git log graph:
|
||||
|
||||
- Let's assume the current branch state:
|
||||
```bash
|
||||
a - b - c - d Main
|
||||
\
|
||||
e - f - g Feature
|
||||
```
|
||||
|
||||
- Ensure that we'are working in the `main` branch:
|
||||
```bash
|
||||
git checkout main
|
||||
```
|
||||
|
||||
- Then let's execute the following `cherry-pick` command:
|
||||
```bash
|
||||
git cherry-pick f
|
||||
```
|
||||
|
||||
- Once executed, branch state will change to:
|
||||
```bash
|
||||
a - b - c - d - f Main
|
||||
\
|
||||
e - f - g Feature
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
The `git cherry-pick` command has a few options that you can use to customize its behavior:
|
||||
|
||||
* `-n`: Preview the changes without actually applying them.
|
||||
* `-e`: Edit the commit message before applying it.
|
||||
* `-s`: Sign the commit with your GPG key.
|
||||
* `-S[<keyid>]`: Sign the commit with the specified GPG key.
|
||||
|
||||
|
||||
## git remote
|
||||
|
||||
## git blame
|
||||
|
|
Loading…
Reference in a new issue