Last active
April 18, 2022 16:09
-
-
Save fcmendoza/5284c805cd1b45f2ff34cbda71bef7d4 to your computer and use it in GitHub Desktop.
Geet Get Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See comments for examples |
Get specific commit
# this is a bash function
revert-to() { # $1 is the commit hash
git reset $1 && git checkout . && git super-clean && git log -11
}
Overwrite local with remote
# this is a bash function
bitbucket-wins() { # $1 is the branch name: e.g.: fma/CPAC-183-new-petitions
git fetch --all && git reset --hard origin/$1
}
# usage: bitbucket-wins branch-name
Git Aliases
Put the following in ~/.gitconfig
[alias]
nuke-last-commit = reset --hard HEAD~1
superclean = clean -fdx
super-clean = clean -fdx
Git log format
[log]
date = short
[format]
pretty = tformat:"%C(yellow)%h %C(cyan)%ad%Creset%x09%an%x09%Cgreen%s%Creset"
That will give you something like this:
Compare specific file between two branches
git difftool master..feature/test-branch -- src/Core/DataAccess/Repositories/Dynamo/DynamoRepository.cs
Viewing (1/1): 'src/Core/DataAccess/Repositories/Dynamo/DynamoRepository.cs'
Launch 'bcomp' [Y/n]? y
In ~/.gitconfig
I have BeyondCompare as the diff tool configured
[diff]
tool = bcomp
[difftool]
prompt = true
[difftool "bcomp"]
trustExitCode = true
cmd = "/c/Users/John/Downloads/bc4/bcomp" \"$LOCAL\" \"$REMOTE\"
Source: https://devconnected.com/how-to-compare-two-git-branches/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create Branch
For microservices branch is off master
cd /to/brach/dir git checkout master git pull git checkout -b fma/MITB-130-xray git push origin fma/MITB-130-xray git branch --set-upstream-to=origin/fma/MITB-130-xray fma/MITB-130-xray git log -11