User Tools

Site Tools


snippets:git

**This is an old revision of the document!**

git

git push --force

git fetch
git reset origin/master --hard

remove last commit, but keep changes

git reset HEAD~ 

tree on console

git config --global alias.tree "log --oneline --decorate --all --graph"
snippet.bash
#!/bin/bash
 
GIT_DIR=/tmp/example/.git
WORK_DIR=/tmp/example/
 
BRANCHES=('feature1', 'feature2')
 
set -x
 
for i in "${BRANCHES[@]}"
do
    git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} checkout ${i}
    git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} rebase master
    git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} push -f
 
done
 
git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} checkout master

ignore changes in tracked file

git update-index --assume-unchanged file

To undo and start tracking again:

git update-index --no-assume-unchanged [<file> ...]
snippets/git.1551347140.txt.gz · Last modified: by allspark