mirror of
https://gitlab.com/ric_harvey/git-guide.git
synced 2024-11-23 20:24:02 +00:00
56 lines
No EOL
1.1 KiB
Markdown
56 lines
No EOL
1.1 KiB
Markdown
## Git Cheatsheet
|
|
|
|
```
|
|
# Clone a Repository
|
|
git clone <repository_url>
|
|
|
|
# Stage Changes for Commit
|
|
git add <file(s)>
|
|
|
|
# Commit Changes
|
|
git commit -m "Commit message"
|
|
|
|
# Push Changes to the Remote Repository
|
|
git push
|
|
|
|
# Force Push Changes (use with caution)
|
|
git push --force
|
|
|
|
# Reset Working Directory to Last Commit
|
|
git reset --hard
|
|
|
|
# Create a New Branch
|
|
git branch <branch_name>
|
|
|
|
# Switch to a Different Branch
|
|
git checkout <branch_name>
|
|
|
|
# Merge Changes from Another Branch
|
|
git merge <branch_name>
|
|
|
|
# Rebase Changes onto Another Branch (use with caution)
|
|
git rebase <base_branch>
|
|
|
|
# View Status of Working Directory
|
|
git status
|
|
|
|
# View Commit History
|
|
git log
|
|
|
|
# Undo Last Commit (use with caution)
|
|
git reset --soft HEAD^
|
|
|
|
# Discard Changes in Working Directory
|
|
git restore <file(s)>
|
|
|
|
# Retrieve Lost Commit References
|
|
git reflog
|
|
|
|
# Interactive Rebase to Rearrange Commits
|
|
git rebase --interactive HEAD~3
|
|
```
|
|
|
|
---
|
|
##### Follow me for more guides
|
|
|
|
[<img src="./img/mastodon.png" width="8%">](https://awscommunity.social/@Ric)[<img src="./img/linkedin.png" width="5%">](https://www.linkedin.com/in/richarvey/) |