All Projects → onmyway133 → awesome-git-commands

onmyway133 / awesome-git-commands

Licence: other
🍴 Indispensable git commands for everyday use

Projects that are alternatives of or similar to awesome-git-commands

Bump
Bump updates the project's version, updates/creates the changelog, makes the bump commit, tags the bump commit and makes the release to GitHub. Opinionated but configurable.
Stars: ✭ 327 (+516.98%)
Mutual labels:  tag, commit
gradle-git-versioning-plugin
This extension will set project version, based on current Git branch or tag.
Stars: ✭ 44 (-16.98%)
Mutual labels:  tag, branch
fzf-checkout.vim
Manage branches and tags with fzf
Stars: ✭ 187 (+252.83%)
Mutual labels:  tag, branch
bashy
Extremely fast and simple git prompt for bash and zsh
Stars: ✭ 43 (-18.87%)
Mutual labels:  command, repo
artisan-aliases
Save keystrokes and run Artisan commands your way
Stars: ✭ 23 (-56.6%)
Mutual labels:  command
auto-commit-msg
A VS Code extension to generate a smart commit message based on file changes
Stars: ✭ 61 (+15.09%)
Mutual labels:  commit
Kopano
Scripts for Kopano
Stars: ✭ 25 (-52.83%)
Mutual labels:  repo
CyberPunkNetrunner
Cyberpunk 2077 Netrunner Hacking Tool (Easy to use and install). Don't use it on illegal and malicious activity. Inspired by the game CyberPunk 2077 https://www.cyberpunk.net/
Stars: ✭ 69 (+30.19%)
Mutual labels:  repo
mac-branch-deep-linking
The Branch SDK for Mac OS X - Docs:
Stars: ✭ 15 (-71.7%)
Mutual labels:  branch
bcp-47
Parse and stringify BCP 47 language tags
Stars: ✭ 51 (-3.77%)
Mutual labels:  tag
gw
A Wrapper of a command to watch any changes in filesystem
Stars: ✭ 16 (-69.81%)
Mutual labels:  command
lookpath
The minimum and most straightforward way to check if command exists and where the executable is, without spawning child_process.
Stars: ✭ 49 (-7.55%)
Mutual labels:  command
edit
A stand-alone implementation of the Acme text editor's command language.
Stars: ✭ 29 (-45.28%)
Mutual labels:  command
tpack
Pack a Go workflow/function as a Unix-style pipeline command
Stars: ✭ 55 (+3.77%)
Mutual labels:  command
branch-names
Github action to retrieve branch or tag names with support for all events.
Stars: ✭ 99 (+86.79%)
Mutual labels:  branch
SSCTaglistView
Customizable iOS tag list view, in Swift.
Stars: ✭ 54 (+1.89%)
Mutual labels:  tag
command-flow
A flexible command framework and dispatcher which removes lots of boilerplate code used in commands. While it is used generally on Bukkit it is platform agnostic
Stars: ✭ 103 (+94.34%)
Mutual labels:  command
tag-picker
Better tags input interaction with JavaScript.
Stars: ✭ 27 (-49.06%)
Mutual labels:  tag
NYSMC
马甲包框架🔨Auto Choose Sheel/Application framework.
Stars: ✭ 22 (-58.49%)
Mutual labels:  branch
fzf-marker
The terminal command tweak from @pindexis/marker
Stars: ✭ 22 (-58.49%)
Mutual labels:  command

awesome git commands Awesome

🍴 Useful git commands for everyday use

❤️ Support my apps ❤️

❤️❤️😇😍🤘❤️❤️

Table of contents

Checking

Status

Check the status of working directory and staging area

git status

Show changes between HEAD and working directory

git diff

Log

Show the list of commits in one line format

git log --oneline

Show commits that make add or remove a certain string

git log -S 'LoginViewController'

Search commits that contain a log message

git log — all — grep=’day of week’

Check out

Checkout a tag

git checkout TAG
git checkout -b BRANCH TAG

Checkout a branch

git checkout BRANCH

Use -m if there is merge conflict

git checkout -m BRANCH

Checkout a commit

git checkout COMMIT_HASH

Checkout into a new branch

git checkout -b BRANCH HEAD~4
git checkout -b BRANCH COMMIT_HASH

Checkout a file in a commit

git checkout COMMIT -- FILE_PATH

Checkout file at a specific commit and open in Visual Studio Code

git show BRANCH_TAG_COMMIT:FILE_PATH | code -

Diff

Make and apply diff file between 2 branches

git diff BRANCH ANOTHER_BRANCH > file.diff
git apply file.diff

Searching

Find bug in commit history in a binary search tree style:

git bisect start
git bisect good
git bisect bad

Committing

Tag

List all tags

git tag

Tag a commit

git tag -a TAG -m "TAG MESSAGE"

Delete remote tags

git push --delete REMOTE TAG
git push origin :TAG

Push tag to remote

git push REMOTE TAG

Rename tag

git tag NEW_TAG OLD_TAG
git tag -d OLD_TAG

Move tag from one commit to another commit

git push origin :TAG
git tag -fa TAG
git push REMOTE --tags

Remote

List all remote

git remote

Rename remote

git remote rename OLD_REMOTE NEW_REMOTE

Remove stale remote tracking branches

git remote prune REMOTE

Branch

List all branches

git branch

Create the branch on your local machine and switch in this branch

git checkout -b BRANCH

Create branch from commit

git branch BRANCH COMMIT_HASH

Push the branch to remote

git push REMOTE BRANCH

Rename other branch

git branch -m OLD_BRANCH NEW_BRANCH

Rename current branch

git branch -m NEW_BRANCH

Rename remote branch

git branch -m OLD_BRANCH NEW_BRANCH        # Rename branch locally    
git push origin :OLD_BRANCH                # Delete the old branch    
git push --set-upstream REMOTE NEW_BRANCH  # Push the new branch, set local branch to track the new remote

Delete a branch locally and remote

git branch -D BRANCH
git push REMOTE :BRANCH

Delete all local branches but master

git branch | grep -v "master" | xargs git branch -D

Commit

Undo last commit

git reset --hard HEAD~1

Squash last n commits into one commit

git rebase -i HEAD~5

git reset --soft HEAD~5
git add .
git commit -m "Update"
git push -f origin master

Move last commits into new branch:

git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch

Make changes to older commit

git rebase -i HEAD^^^
// change from pick to edit, then :wq
git add .
git rebase --continue

Merge

Get their changes during git merge

git pull -X theirs git checkout --theirs FILE_PATH git checkout --theirs . git add .

git checkout BRANCH_A git merge -X theirs BRANCH_B

Merge commits from master into feature branch

git checkout BRANCH
git merge --no-ff BASE_BRANCH

Fixup

After commit, in interactive rebase, specify fixup instead of pick

git commit --fixup HEAD~1
git rebase HEAD~2 -i --autosquash
git commit --fixup fb2f677
git rebase -i --autosquash ac5db87

Cherry Pick

Add some commits to the top of the current branch:

git cherry-pick COMMIT_HASH_A COMMIT_HASH_B

Rewriting History

Revert

Revert the previous commit

git revert HEAD

Revert the changes from previous 3 commits without making commit

git revert --no-commit HEAD~3..

Amend

Amend previous commit

git commit --amend
git commit --amend --no-edit
git commit --amend -m "COMMIT_MESSAGE"

Changing git commit message after push

git commit --amend -m "COMMIT_MESSAGE"
git push --force REMOTE BRANCH

Reflog

Show reflog

git reflog

Get commit

git reset --hard COMMIT_HASH
git cherry-pick COMMIT_HASH

Rebase

Rebase the current branch onto another branch

git rebase BASE_BRANCH

Continue rebase

git rebase --continue

Abort rebase

git rebase --abort

Get their changes during git rebase

git checkout --ours FILE_PATH
git add FILE_PATH

Tracking

Index

Remove untracked files

git clean

Remove file from index

git reset FILE_PATH

Reset the index to match the most recent commit

git reset

Reset the index and the working directory to match the most recent commit

git reset --hard

Ignore

Un-track files that have just been declared in .gitignore

git rm -r --cached .
git add .
git commit -am "COMMIT_MESSAGE"

Stashing

Stash

Save a change to stash

git stash save "STASH_NAME"
git stash

List all stashes

git stash list

Apply a stash

git stash pop
git stash apply
git stash apply stash@{2}

Read more

This is just scratching the surface of what git can do, if you want to learn more, here are some links to get started.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].