export GIT_TRACE=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
git clean --dry-run
git clean -f -q
# remove all remote non-used branches
git remote prune origin
git reset --hard
git reset --hard origin/master
# find full path to the file
file_name="integration_test.sh.j2"
git log --diff-filter=D --name-only | grep $file_name
# find last log messages
full_path="ansible/roles/data-ingestion/templates/integration_test.sh.j2"
git log -2 --name-only -- $full_path
second_log_commit="99994ccef3dbb86c713a44815ab5ffa"
# restore file from specific commit
git checkout $second_log_commit -- $full_path
# show removed file
git show $second_log_commit:$full_path
git reset --hard HEAD~1
git checkout -t origin/develop
git remote prone origin
git branch -d release-6.9.0
git branch --delete release-6.9.0
# delete with force - for non-merged branches
git branch -D origin/release/2018.05.00.12-test
# the same as
git branch -d -f release-6.9.0
git branch --delete --force origin/release/2018.05.00.12-test
git push origin --delete release/2018.05.00.12-test
git gc --prune=now
git fetch --prune
git branch --merged | egrep -v "(^\*|master|in-progress)" | xargs git branch -d
commit1=10141d299ac14cdadaca4dd586195309020
commit2=b6f2f57a82810948eeb4b7e7676e031a634 # should be removed and not important
commit3=be82bf6ad93c8154b68fe2199bc3e52dd69
current_branch=my_branch
current_branch_ghost=my_branch_2
git checkout $commit1
git checkout -b $current_branch_ghost
git cherry-pick $commit3
git push --force origin HEAD:$current_branch
git reset --hard origin/$current_branch
git branch -d $current_branch_ghost
git rev-parse "remotes/origin/release-6.0.0"
check all branches for certain commit ( is commit in branch, is branch contains commit ), commit include in
git branch --all --contains 0ff27c79738a6ed718baae3e18c74ba87f16a314
git branch --all --contains {name-of-the-branch}
git branch --all --merged 0ff27c79738a6ed718baae3e18c74ba87f16a314
git merge-base --is-ancestor <ancestor_commit> <descendant_commit>; if [[ 1 -eq "$?" ]]; then echo "NOT included"; else echo "included"; fi
git log -5 develop
git log -10 --author "Frank Newman" -- data-api
git log -5 develop --name-only
git log -10 --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --all --author "Cherkashyn"
git shortlog -sne --all
git whatchanged --author="Cherkashyn" --name-only
git log --author="Cherkashyn" --name-status --diff-filter=M | grep "^M" | sort | uniq -c | sort -rh
git diff-tree --no-commit-id --name-only -r ec3772
git diff ec3772~ ec3772
git log --all --graph --decorate --oneline --simplify-by-decoration
git branch --no-merged
git checkout -t remotes/origin/release
git checkout experiment -- deployment/connection_pool.py
git config --global user.name "vitalii cherkashyn"
git config --global user.email [email protected]
git config --global --list
or
# git config --global --edit
[user]
name=Vitalii Cherkashyn
email[email protected]
git config --global core.editor "vim"
git config --global credential.helper store
git config --system --unset credential.helper
git config --global --unset credential.helper
git branch --all --merged "release" --verbose
git branch --all --no-merged "release" --verbose
git branch -vv
git diff --name-status develop release-6.0.0
git cherry develop release-6.0.0
git diff develop..master -- myfile.cs
git diff master -- myfile.cs
git diff --staged
git rev-list master..search-client-solr
# by author
git rev-list --author="Vitalii Cherkashyn" item-598233..item-530201
# list of files that were changed
git show --name-only --oneline `git rev-list --author="Vitalii Cherkashyn" item-598233..item-530201`
branch_source="master"
branch_dest="feature-2121"
file_name="src/libs/service/message_encoding.py"
# check
git diff $branch_dest..$branch_source $file_name
# apply
git checkout $branch_source -- $file_name
# check
git diff $branch_source $file_name
git show-ref --tags
git diff --name-only --diff-filter=U
git checkout --theirs path/to/file
git fetch --all --prune
git log --all --grep "BCM-642"
git grep '^test$'
git rev-parse HEAD
git log --all -- "**db-update.py"
git log --all -- db-scripts/src/main/python/db-diff/db-update.py
git log path/to/file
git diff-tree --no-commit-id --name-only -r 6dee1f44f56cdaa673bbfc3a76213dec48ecc983
git fetch --all
git diff HEAD..origin/develop
git show 143243a3754c51b16c24a2edcac4bcb32cf0a37d -- db-scripts/src/main/python/db-diff/db-update.py
git diff {hash}~ {hash}
git cherry-pick -n {commit-hash}
# in case of merge conflict during cherry-pick
git cherry-pick --continue
git cherry-pick --abort
git cherry-pick --skip
# !!! don't use "git commit"
git revert <commit>
git commit --amend -m "<new message>"
git log --pretty=format:"%h - %an, %ar : %s" <commit SHA> -1
git blame path/to/file
git blame path/to/file | grep search_line
git --git-dir=C:\project\horus\.git --work-tree=C:\project\horus branch --all
find . -name ".git" -maxdepth 2 | while read each_file
do
echo $each_file
git --git-dir=$each_file --work-tree=`dirname $each_file` status
done
git remote -v
git remote set-url origin [email protected]:adp/data-management.git
if during the access ( clone, pull ) issue appear:
fatal: unable to access 'http://localhost:3000/vitalii/sensor-yaml.git/': The requested URL returned error: 407
or
fatal: unable to access 'http://localhost:3000/vitalii/sensor-yaml.git/': The requested URL returned error: 503
use next command to 'simulate' cloning
git clone http://localhost:3000/vitalii/sensor-yaml.git
< equals >
wget http://localhost:3000/vitalii/sensor-yaml.git/info/refs?service=git-upload-pack
git clone --depth 1 https://github.com/kubernetes/minikube
git archive --remote=ssh://https://github.com/cherkavi/cheat-sheet HEAD jenkins.md
git remote update origin --prune
git tag -a $newVersion -m 'deployment_jenkins_job'
git push --tags $remoteUrl
echo 'deb http://http.debian.net/debian wheezy-backports main' > /etc/apt/sources.list.d/wheezy-backports-main.list
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
git lfs pull
if you are using SSH access to git, you should specify http credentials ( lfs is using http access ), to avoid possible errors: "Service Unavailable...", "Smudge error...", "Error downloading object"
git config --global credential.helper store
file .gitconfig will have next section
[credential]
helper = store
file ~/.git-credentials ( default from previous command ) should contains your http(s) credentials
https://username:[email protected]
https://username:[email protected]
be aware about upper case for environment variables
NO_PROXY=localhost,127.0.0.1,.localdomain,.advantage.org
HTTP_PROXY=muc.proxy
HTTPS_PROXY=muc.proxy
git config --global http.proxy 139.7.95.74:8080
# proxy settings
git config --global http.proxy http://proxyuser:[email protected]:8080
git config --global https.proxy 139.7.95.74:8080
git config --global --get http.proxy
git config --global --unset http.proxy
git config core.sshCommand 'ssh -i private_key_file'
.gitattributes
*.sh -crlf
curl -s https://api.github.com/repos/bugy/script-server/releases/latest | grep browser_download_url | cut -d '"' -f 4
wget https://raw.githubusercontent.com/cherkavi/cheat-sheet/master/git.md
#git settings parse_git_branch() {
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
git update-index --assume-unchanged .idea/vcs.xml
mv .git/hooks/commit-msg.sample .git/hooks/commit-msg
result=`cat $1 | grep "^check-commit"`
if [ "$result" != "" ]; then
exit 0
else
echo "message should start from 'check-commit'"
exit 1
fi