All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 4s
118 lines
1.5 KiB
Markdown
118 lines
1.5 KiB
Markdown
# Git
|
|
|
|
|
|
---
|
|
|
|
## Clone a repository
|
|
Copy an existing remote repository to your local machine.
|
|
|
|
```bash
|
|
git clone <repository_url>
|
|
```
|
|
Example:
|
|
```bash
|
|
git clone https://github.com/user/repo.git
|
|
```
|
|
|
|
---
|
|
|
|
## Pull changes from remote
|
|
Fetch and merge changes from a remote repository to your local branch.
|
|
|
|
```bash
|
|
git pull <remote> <branch>
|
|
```
|
|
Example:
|
|
```bash
|
|
git pull origin main
|
|
```
|
|
|
|
---
|
|
|
|
## Push changes to remote
|
|
Upload local commits to a remote repository.
|
|
|
|
```bash
|
|
git push <remote> <branch>
|
|
```
|
|
Example:
|
|
```bash
|
|
git push origin main
|
|
```
|
|
|
|
---
|
|
|
|
## Rebase branches
|
|
Reapply commits on top of another base tip.
|
|
|
|
```bash
|
|
git rebase <branch>
|
|
```
|
|
Example:
|
|
```bash
|
|
git rebase main
|
|
```
|
|
|
|
---
|
|
|
|
## Initialize a new repository
|
|
Create a new Git repository in the current directory.
|
|
|
|
```bash
|
|
git init
|
|
```
|
|
|
|
---
|
|
|
|
## Manage remotes
|
|
|
|
- **Add a remote:**
|
|
```bash
|
|
git remote add <name> <url>
|
|
```
|
|
|
|
- **Set/Update remote URL:**
|
|
```bash
|
|
git remote set-url <name> <url>
|
|
```
|
|
|
|
- **Remove a remote (e.g., origin):**
|
|
```bash
|
|
git remote remove origin
|
|
```
|
|
|
|
---
|
|
|
|
## Commit changes with GPG signature
|
|
Sign your commit with a GPG key.
|
|
|
|
```bash
|
|
git commit -S -m "Your commit message"
|
|
```
|
|
- `-S` → sign commit with GPG key
|
|
- `-m` → commit message
|
|
|
|
---
|
|
|
|
## Notes
|
|
- To check the configured remotes:
|
|
```bash
|
|
git remote -v
|
|
```
|
|
- To see commit history:
|
|
```bash
|
|
# Those options only add Styling,
|
|
git log --oneline --graph --all --decorate
|
|
|
|
# Plain Text Log,
|
|
git log
|
|
|
|
```
|
|
|
|
- Stage changes before committing:
|
|
```bash
|
|
git add <file>
|
|
git add . # stage all changes
|
|
```
|
|
|
|
--- |