Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hegdepavankumar/git-cheat-sheet
This Git cheat sheet saves you time when you just can't remember what a command is or don't want to use git help in the command line. It is hard to memorize all the important Git commands by heart, so print this out or save it to your desktop to resort to when you get stuck.
https://github.com/hegdepavankumar/git-cheat-sheet
cmd command git gitcheatsheet gitcommands powershell
Last synced: about 2 months ago
JSON representation
This Git cheat sheet saves you time when you just can't remember what a command is or don't want to use git help in the command line. It is hard to memorize all the important Git commands by heart, so print this out or save it to your desktop to resort to when you get stuck.
- Host: GitHub
- URL: https://github.com/hegdepavankumar/git-cheat-sheet
- Owner: hegdepavankumar
- License: gpl-3.0
- Created: 2022-07-24T15:40:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-10T04:19:15.000Z (about 1 year ago)
- Last Synced: 2024-05-02T04:44:47.238Z (9 months ago)
- Topics: cmd, command, git, gitcheatsheet, gitcommands, powershell
- Language: PowerShell
- Homepage: https://imhegde.github.io/git-cheat-sheet/
- Size: 144 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Git-Cheat-Sheet
![GitHub](https://img.shields.io/github/license/hegdepavankumar/Git-Cheat-Sheet?style=flat)
![GitHub top language](https://img.shields.io/github/languages/top/hegdepavankumar/Git-Cheat-Sheet?style=flat)
![GitHub last commit](https://img.shields.io/github/last-commit/hegdepavankumar/Git-Cheat-Sheet?style=flat)
![ViewCount](https://views.whatilearened.today/views/github/hegdepavankumar/Git-Cheat-Sheet.svg?cache=remove)## Document_Cheat_Sheet
![Download_Document](git-cheat-sheet-education.pdf)
A cheat sheet for uncommon Git commands
## Configuration
| Command | Description |
| - | - |
| `git config --global user.name "foo"` | Set user name |
| `git config --global user.email "[email protected]"` | Set user email |## Branches
| Command | Description |
| - | - |
| `git branch foo` | Create a new branch |
| `git branch -d foo` | Deletes a branch |
| `git switch foo` | Switch to a branch |
| `git switch -c\|--create foo` | Create and switch to a branch |
| `git restore foo.js` | Undo all changes on the foo.js file |
| `git checkout foo.js` | Undo all changes on the foo.js file |
| `git checkout foo` | Use `git switch` instead |
| `git checkout -b foo` | Use `git switch -c` instead |
| `git merge foo` | Merge branch into current branch |## Pulling
| Command | Description |
| - | - |
| `git pull --rebase --prune` | Get latest, rebase any changes not checked in and delete branches that no longer exist |## Staged Changes
| Command | Description |
| - | - |
| `git add file.txt` | Stage file |
| `git add -p`|--patch file.txt` | Stage some but not all changes in a file |
| `git mv file1.txt file2.txt` | Move/rename file |
| `git rm --cached file.txt` | Unstage file |
| `git rm --force file.txt` | Unstage and delete file |
| `git reset HEAD` | Unstage changes |
| `git reset --hard HEAD` | Unstage and delete changes |
| `git clean -f\|--force -d` | Recursively remove untracked files from the working tree |
| `git clean -f\|--force -d -x` | Recursively remove untracked and ignored files from the working tree |## Changing Commits
| Command | Description |
| - | - |
| `git reset 5720fdf` | Reset current branch but not working area to commit |
| `git reset HEAD~1` | Reset the current branch but not working area to the previous commit |
| `git reset --hard 5720fdf` | Reset current branch and working area to commit |
| `git commit --amend -m "New message"` | Change the last commit message |
| `git commit --fixup 5720fdf -m "New message"` | Merge into the specified commit |
| `git revert 5720fdf` | Revert a commit |
| `git rebase --interactive [origin/main]` | Rebase a PR (`git pull` first) |
| `git rebase --interactive 5720fdf` | Rebase to a particular commit |
| `git rebase --interactive --root 5720fdf` | Rebase to the root commit |
| `git rebase --continue` | Continue an interactive rebase |
| `git rebase --abort` | Cancel an interactive rebase |
| `git cherry-pick 5720fdf` | Copy the commit to the current branch |## Compare
| Command | Description |
| - | - |
| `git diff` | See difference between working area and current branch |
| `git diff HEAD HEAD~2` | See difference between te current commit and two previous commits |
| `git diff main other` | See difference between two branches |## View
| Command | Description |
| - | - |
| `git log` | See commit list |
| `git log --patch` | See commit list and line changes |
| `git log --decorate --graph --oneline` | See commit visualization |
| `git log --grep foo` | See commits with foo in the message |
| `git show HEAD` | Show the current commit |
| `git show HEAD^` or `git show HEAD~1` | Show the previous commit |
| `git show HEAD^^` or `git show HEAD~2` | Show the commit going back two commits |
| `git show main` | Show the last commit in a branch |
| `git show 5720fdf` | Show named commit |
| `git blame file.txt` | See who changed each line and when |## Stash
| Command | Description |
| - | - |
| `git stash push -m "Message"` | Stash staged files |
| `git stash --include-untracked` | Stash working area and staged files |
| `git stash --staged` | Stash staged files |
| `git stash list` | List stashes |
| `git stash apply` | Moved last stash to working area |
| `git stash apply 0` | Moved named stash to working area |
| `git stash clear` | Clear the stash |## Tags
| Command | Description |
| - | - |
| `git tag` | List all tags |
| `git tag -a\|--annotate 0.0.1 -m\|--message "Message"` | Create a tag |
| `git tag -d\|--delete 0.0.1` | Delete a tag |
| `git push --tags` | Push tags to remote repository |## Remote
| Command | Description |
| - | - |
| `git remote -v` | List remote repositories |
| `git remote show origin` | Show remote repository details |
| `git remote add upstream ` | Add remote upstream repository |
| `git fetch upstream` | Fetch all remote branches |
| `git rebase upstream/main` | Refresh main branch from upstream |
| `git remote -v` | List remote repositories |
| `git push --force` | Push any changes while overwriting any remote changes |
| `git push --force-with-lease` | Push any changes but stop if there are any remote changes |
| `git push --tags` | Push tags to remote repository |## Submodules
| Command | Description |
| - | - |
| `git submodule status` | Check status of all submodules |- Pull submodules
1. `git submodule sync`
2. `git submodule init`
3. `git submodule update`
- Change branch
1. `cd /submodule`
2. `git fetch origin `
3. `git checkout `
4. `cd /`
## Creators [🔝](#welcome-badges-4-readmemd-profile)| [
@hegdepavankumar](https://github.com/hegdepavankumar) |