sh Git提示

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Git提示相关的知识,希望对你有一定的参考价值。

#!/bin/sh

#
# Git pre-commit hook that prevents really broken Drupal from code being committed.
#
# Created by Dave Hall http://davehall.com.au
#

# Fetch the list of files that have changed.
FILES="$(git diff --staged --name-only HEAD --diff-filter=ACMRTUXB)"

echo "Running PHP lint check" >&2
LINT_FAIL=0
for filename in $FILES; do
  if ! php -l $filename; then
    LINT_FAIL=1
  fi
done;

# There is no point in running PHP Code Sniffer on broken files.
if [ $LINT_FAIL -gt 0 ]; then
  exit 1
fi

echo "Running PHP Code Sniffer Checks" >&2
echo $FILES | xargs phpcs --standard=Drupal

git checkout staging
// Merge content from develop to staging ( all conflicts are resolved auto, and merge all commit in one commit.
git merge --squash -X theirs develop

// Delete config files from staging
rm -rf ../onisep/config/*.*
// Replace directory from develop.
cp -R config ../onisep

// Delete module from staging
rm -rf ../onisep/web/modules/custom/kangae/
// Replace directory from develop.
cp -R web/modules/custom/ ../onisep/web/modules

// Delete theme from staging
rm -rf ../onisep/web/themes/custom/onisep
// Replace directory from develop.
cp -R web/themes/custom/ ../onisep/web/themes

cp composer.lock ../onisep/composer.lock

$ git log --oneline --decorate
xxxxxx3 (HEAD, feature-branch) third commit
xxxxxx2 second commit
xxxxxx1 first commit
xxxxxx0 (master) starting point

If I want to fix something introduced in the second commit I can simply do :

$ git add .
$ git commit --fixup xxxxxx2
$ git log --oneline --decorate
xxxxxx4 (HEAD, feature-branch) fixup! second commit
xxxxxx3 third commit
xxxxxx2 second commit
xxxxxx1 first commit
xxxxxx0 (master) starting point

Notice the fixup! prefix of the commit message ? Now git can use this information to automatically rebase your changes :


$ git rebase --interactive --autosquash master

$ git rebase --interactive --autosquash master


This will open an interactive rebase editor session like you are accustomed to, but your fixup commit will be automatically placed correctly in the list with the correct action :

pick xxxxxx1 first commit
pick xxxxxx2 second commit
fixup xxxxxx4 fixup! second commit
pick xxxxxx3 third commit

Usually, it’s now only a matter of accepting the rebase as is and tada !

If you want to aleays autosquash you can simply add it to your config :

git config --global rebase.autosquash true

I also defined some aliases to help :


fix = commit --fixup HEAD~1 # fixup the last commmit
fixup = commit --fixup # fixup a commit in the history (need a revision)
squash = commit --squash # squash a commit in the history (need a revision)
ri = rebase --interactive # interactive rebase

fix = commit --fixup HEAD~1 # fixup the last commmit
fixup = commit --fixup # fixup a commit in the history (need a revision)
squash = commit --squash # squash a commit in the history (need a revision)
ri = rebase --interactive # interactive rebase
git status -s | grep -E '^ D' | cut -d ' ' -f3 | xargs git add --all
// Get last tag in current branch.
git describe --tags --abbrev=0
git config core.filemode false

git update-index --chmod=+x foo.sh
git checkout branchA
git merge -X theirs branchB
// List branch with remotes tracking.
git branch -vv
// get first commint on the current branch
git rev-list --max-parents=0 HEAD

以上是关于sh Git提示的主要内容,如果未能解决你的问题,请参考以下文章

sh git优化了bash提示符

sh 颜色有趣你的bash提示+ git分支

sh 更改PS1提示+添加git分支

git允许sh文件提示没有找到路径

sh 根据活动的virtualenv,git branch和last命令的返回状态设置颜色bash提示符。

sh 根据活动的pyenv,git branch和last命令的返回状态设置颜色bash提示符。