Assume commit history ‘A’-c-c-c-c-‘B’-c-c-c-c-c-‘C’
- you want to cleanup the commits from ‘A’ to ‘B’
$ git reset —hard B
$ git reset A
You might use this technique by creating branch ‘B’ if necessary.
| . ~/.bash_colors | |
| if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
| . $(brew --prefix)/etc/bash_completion | |
| export PS1=$txtred'[\W]'$txtylw'$(__git_ps1)'$txtrst' \$ ' | |
| fi | |
| export GIT_PS1_SHOWUPSTREAM=auto | |
| export GIT_PS1_SHOWDIRTYSTATE=1 | |
| export GIT_PS1_SHOWSTASHSTATE=1 | |
| export GIT_PS1_SHOWUNTRACKEDFILES=1 |
| [alias] | |
| br = branch | |
| ci = commit | |
| st = status | |
| put = push origin HEAD | |
| co = checkout | |
| [core] | |
| repositoryformatversion = 0 | |
| filemode = true | |
| bare = false | |
| logallrefupdates = true | |
| precomposeunicode = false | |
| [push] | |
| default = simple | |
| [credential] | |
| helper = cache --timeout 1 | |
| [remote "origin"] | |
| url = https://[email protected]/project/product.git | |
| fetch = +refs/heads/*:refs/remotes/origin/* | |
| [branch "master"] | |
| remote = origin | |
| merge = refs/heads/master |
| ## | |
| ## temporarily ignore files | |
| ## http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html | |
| ## | |
| git update-index --assume-unchanged <file> | |
| git update-index --no-assume-unchanged <file> | |
| ## | |
| ## config: (per repo) user.name, user.email | |
| ## | |
| $ git config user.name "Your Name" | |
| $ git config user.email [email protected] | |
| ## | |
| ## config: (global) user.name, user.email | |
| ## | |
| $ git config --global user.name "Your Name" | |
| $ git config --global user.email [email protected] | |
| ## | |
| ## config: push.default changed from matching to simple | |
| ## | |
| git config --global push.default simple | |
| ## | |
| ## amending a commit to reset author | |
| ## | |
| $ git commit --amend --reset-author | |
| ## | |
| ## http://git-scm.com/docs/git-credential-cache | |
| ## | |
| $ git config credential.helper 'cache --timeout=1' | |
| ## | |
| ## http://stackoverflow.com/questions/15381198/remove-credentials-from-git | |
| ## | |
| git config --global --unset credential.helper | |
| ## | |
| ## https://help.github.com/articles/updating-credentials-from-the-osx-keychain | |
| ## | |
| $ git credential-osxkeychain erase | |
| host=github.com | |
| protocol=https | |
| # [Hit return] |
| #!/bin/bash | |
| echo "ufetch : select user" | |
| USERS=( | |
| "jessica.tate" | |
| "jon.doe" | |
| "luther.baker" | |
| ) | |
| for idx in "${!USERS[@]}" | |
| do | |
| echo "$idx) ${USERS[$idx]}" | |
| done | |
| read -p"> " USERNUM | |
| USERNAME=${USERS[$USERNUM]} | |
| ORIG_URL=$(git config --get remote.origin.url) | |
| NEW_URL=$(echo "$ORIG_URL" | sed -e"s|https://[^@]*@gitlab\.replace_domain\.com|https://${USERNAME}@gitlab.replace_domain.com|") | |
| git config --replace-all remote.origin.url "$NEW_URL" | |
| git config --replace-all user.name "$USERNAME" | |
| git config --replace-all user.email "$USERNAME@replace_domain.com" | |
| echo | |
| echo "Running the following command as $USERNAME:" | |
| echo " git fetch $@" | |
| echo | |
| git fetch "$@" |
Change the author of a commit in Git
git filter-branch -f —env-filter "
GIT_AUTHOR_NAME=‘Newname’
GIT_AUTHOR_EMAIL=‘newemail’
GIT_COMMITTER_NAME=‘Newname’
GIT_COMMITTER_EMAIL=‘newemail’
" HEAD
| if ! git diff-index --quiet HEAD --; then | |
| # do this to simply log the changes to the console (for later inspection) | |
| git diff | |
| # do this because we need to add, comimt and push | |
| # note that the comment, the path and the branch are hardcoded | |
| git --git-dir=/Users/jenkins/.jenkins/.git --work-tree=/Users/jenkins/.jenkins commit -a -m "Automatic evening repository update." && git push origin master | |
| fi |
git --git-dir=/mycode/.git --work-tree=/mycode status
if ! git diff-index --quiet HEAD --; then
VN="$VN-mod"
fi
good-cmd && echo "succeeded" || echo "failed"
bad-cmd || {
recovery-cmd ||
echo "recovery failed &&
echo "recovered"
}
ffmpeg <your args>
RC=$?
if [ "${RC}" -ne "0" ]; then
# Do something to handle the error.
else
# Everything was ok.
fiCheck
git config --local credential.helper
git config --global credential.helper
git config --system credential.helper
Unset
git config --local --unset credential.helper
git config --global --unset credential.helper
git config --system --unset credential.helper