https://github.com/touppercase78/useful-git-commands
Useful Git commands can be found here.
https://github.com/touppercase78/useful-git-commands
cheatsheets git useful
Last synced: 5 months ago
JSON representation
Useful Git commands can be found here.
- Host: GitHub
- URL: https://github.com/touppercase78/useful-git-commands
- Owner: toUpperCase78
- Created: 2021-01-08T12:11:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-04-07T15:05:11.000Z (about 3 years ago)
- Last Synced: 2025-06-02T12:05:41.523Z (about 1 year ago)
- Topics: cheatsheets, git, useful
- Language: HTML
- Homepage:
- Size: 1.55 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# useful-git-commands
I've seen lots of cheat sheets from various sources ion the Internet, presents many commands related to Git version control. Here are the most useful ones below:
_Also uploaded Git Cheat Sheets images that explain the commands with some visuals. Be sure to check them out above!_
### CREATE
Clone an existing repository: `$ git clone `
Create a new local repository: `$ git init`
### LOCAL CHANGES
See the latest status in your working directory: `$ git status`
See changes to tracked files: `$ git diff`
See changes between two commits: `$ git diff `
Add all current changes to the next commit: `$ git add .`
Add some changes in file to the next commit: `$ git add -p `
Commit all local changes in tracked files: `$ git commit -a`
Commit previously staged changes: `$ git commit`
Commit staged changes with a message: `$ git commit -m `
All all changes made to tracked files and commit: `$ git commit -am `
Change the last commit: `$ git commit --amend`
### COMMIT HISTORY
Show all commits, starting with the newest on top: `$ git log`
Show changes over time for a specific file: `$ git log -p `
Who changed what and when in file: `$ git blame `
### BRANCHES & TAGS
List all existing branches: `$ git branch`
Switch to the branch: `$ git checkout `
Create a new branch based on your current HEAD: `$ git branch `
Create a new branch and switch to it: `$ git checkout -b `
Create a new tracking branch based on a remote branch: `$ git checkout --track `
Delete a local branch: `$ git branch -d `
Mark the current commit with a tag: `$ git tag `
### UPDATE & PUBLISH
List all currently configured remotes: `$ git remote -v`
Show information about a remote: `$ git remote show `
Add new remote repository, named 'remote': `$ git remote add `
Download all changes from 'remote', but don't integrate into HEAD: `$ git fetch `
Download changes and directly merge/integrate into HEAD: `$ git pull `
Publish local changes on a remote: `$ git push `
Delete a branch on the remote: `$ git branch -dr `
Publish your tags: `$ git push --tags`
### MERGE & REBASE
Merge branch into your current HEAD: `$ git merge `
Rebase your current HEAD onto branch: `$ git rebase `
Abort a rebase: `$ git rebase --abort`
Continue a rebase after resolving conflicts: `$ git rebase --continue`
User your configured merge tool to solve conflicts: `$ git mergetool`
### UNDO
Move/rename a file and stage move: `$ git mv `
Remove a file from working directory and staging area, then stage the removal: `$ git rm `
Remove from staging area only: `$ git rm --cached `
Discard all local changes in your working directory: `$ git reset --hard HEAD`
Discard local changes in a specific file: `$ git checkout HEAD `
Revet a commit (by producing a new commit with contrary changes): `$ git revert `
Reset your HEAD pointer to a previous commit and discard all changes since then: `$ git reset --hard `
And preserve all changes as unstaged changes: `$ git reset `
And preserve uncommitted local changes: `$ git reset --keep `
## Previously...
I had performed a demonstration to push files from my local repository to this remote repo here.
It worked by using `git push`, including two other git commands beforehand: `remote` and `branch`
These commands had been entered inside git bash while in my local directory:
* `git remote add origin `
* `git branch -M main`
* `git push -u origin main`