git hooks post-merge example


# check for modified files
for FILE in $(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD); do
  case "${FILE}" in
      # Repository configuration changed: update configuration
      # Crontab changed: update user cronjobs

# show repository info
git describe
git config -l

# show commit info
git show

# show diff for one file
git diff

# commit only one file
git commit -m 'my comment' path/to/file

# create Git repository
git init

# add all files
git add .

# commit
git commit -m "initial project version"

# list tag
git tag -l

# checkout over SSH
git clone

# pull single file
git checkout filename

# pull single file from remote
git checkout origin/master -- path/to/file
# pull all files from remote
git checkout origin/dev -- .

# sync changes from other branch
git rebase master
git rebase brach1

# checkout to checkout to specific folder
git clone /path/to/folder

# create tag
git tag -a v1.4 -m 'version 1.4'
git push --tags
git push origin

# remove tag
git tag -d tag123
git push origin :refs/tags/tag123

# checkout tag
git clone --branch bar-1.0.4 /tmp/bar-1.0.4

# git pull single file
git checkout origin/master -- file_name

# checkout commit
git checkout commit_hash

# reset branch
git reset --hard origin/master
git reset --hard origin/branch123
git reset --hard

# rollback to revision
git checkout 96fe40ded8277725d244aac83c42256ad554cc3b .

# create branch
git checkout -b branch_name

# switch branch
git checkout branch_name
git checkout master

# checkout branch
git clone --branch --single-branch []

# diff all files betwen braches
git diff dev..stage

# diff singe file between branches
git diff dev..stage file1

# diff branches and show file name only
git diff --name-only dev..stage

# diff differnet fiels in different branches
git diff branch1:file branch2:file

# test
git reset file/to/overwrite

# search for string
git grep "string/regexp" $(git rev-list --all)

# grep
git grep foo HEAD

# remove last commit
git reset HEAD~1

# reset to latest revision
git reset --hard

# reset to commit-id
git reset --hard
git push origin HEAD --force

git cherry-pick commit1

# diff between branches
git diff master

# show branches
git branch

# push local Git branch to remote master branch
git push origin local_branch_1:master

# delete local branch
git branch -d local_branch_name

# delete remote branch
git push origin :remote_branch_name

# delete directory / file from git repository without removing from disk
git rm --cached -r DIR1

# ignore

# git global setup
git config --global "first_name last_name"
git config --global ""
git config --global core.autocrlf true

# create a new repository
git clone
cd repository_name
git add
git commit -m "add README"
git push -u origin master

# Add existing folder or Git repository
cd existing_folder
git init
git remote add origin
git add .
git commit
git push -u origin master

# search for string in commit
git grep foo $(git rev-list --all)

# check out single file
git archive HEAD:path1/file_or_dir target_file_name | tar --extract

# set proxy
git config --global http.proxy $http_proxy
git config --global https.proxy $https_proxy

# undo changes on file
git checkout -- file

# inclue a commit
git cherry-pick commit1


# pass GIT settings over SSH
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example -F /dev/null" git clone example
git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"

git rm --cached roles/icinga-client
git submodule add roles/icinga-client

# update submodule
git submodule update --recursive --remote