Basic Commands
- Restore file
git restore file_path
- Rename or move:
git mv file_path new_name_or_path
- Log
git log —oneline —graph —decorate
- Last 3 days
—since=“3 days ago”
- Follow renamed file
—follow
- Log a file
— file/path
- Check a commit
git show commit_id
- Alias git
git config —global alias.hist “log —all —oneline —graph —decorate”
Now we can use git hist
- Compare commit
git diff old_commit HEAD
- HEAD^ is commit prior to HEAD
- Compare local to remote
git diff master origin/master
Continuous Deploy
name: CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2.1.5
- name: Install dependencies
run: npm ci
- name: Generate
run: npm run build:docs
- name: Deploy to GH Pages
run: |
git config --global user.email ${{secrets.GIT_EMAIL}}
git config --global user.name ${{secrets.GIT_USERNAME}}
git remote set-url origin https://${{secrets.GIT_TOKEN}}@github.com/xiaosasori/my-vue-components.git
npm run deploy
Change commited username, user email
force=''
if test "x$1" = "x-f"; then
force='-f'
shift
fi
die() {
printf '%s\n' "$@"
exit 128
}
targ="$(git rev-parse --verify "$1" 2>/dev/null)" || die "$1 is not a commit"
br="${2:-HEAD}"
TARG_COMMIT="$targ"
TARG_NAME="${3-}"
TARG_EMAIL="${4-}"
export TARG_COMMIT TARG_NAME TARG_EMAIL
filt='
if test "$GIT_COMMIT" = "$TARG_COMMIT"; then
if test -n "$TARG_EMAIL"; then
GIT_AUTHOR_EMAIL="$TARG_EMAIL"
export GIT_AUTHOR_EMAIL
else
unset GIT_AUTHOR_EMAIL
fi
if test -n "$TARG_NAME"; then
GIT_AUTHOR_NAME="$TARG_NAME"
export GIT_AUTHOR_NAME
else
unset GIT_AUTHOR_NAME
fi
fi
'
git filter-branch $force --env-filter "$filt" -- $br
#!/bin/sh
git filter-branch -f --env-filter '
OLD_EMAIL="leon.minhanh@gmail.com"
CORRECT_NAME="xiaosasori"
CORRECT_EMAIL="xiaosasori@gmail.com"
if [ "$GIT_COMMITTER_NAME" = "leonanhnm" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "leonanhnm" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags