# Git notes ## Rebase ### Move part file to another commit * rebase interactive * edit commit * remove lines * commit* create new commits for squash later ```bash https://rietta.com/blog/git-patch-manual-split/ https://romanofskiat.wordpress.com/2015/05/12/git-moving-partial-changes-between-commits/ git commit --reuse-message=HEAD@{1} ```` Relative Refs - https://www.atlassian.com/git/tutorials/refs-and-the-reflog - https://stackoverflow.com/questions/2221658/whats-the-difference-between-head-and-head-in-git ``` HEAD~1 HEAD~ HEAD^1 HEAD^ HEAD@{1} ``` ## Full ssh address for remote server ``` git remote set-url origin ssh://lachtan@byt13.fnet.cz:22002/home/lachtan/git/work/linux-workspace.git git remote set-url origin ssh://lachtan@byt13.fnet.cz:22002/~/git/work/linux-workspace.git ``` ```bash # How to Write a Git Commit Message # https://chris.beams.io/posts/git-commit/ GIT_PROMPT_ONLY_IN_REPO=1 source $HOME/.bash-git-prompt/gitprompt.sh # start nove lokalni vetve git checkout -b new_branch # start lokalni vetve navazanou na remote git checkout -b serverfix origin/serverfix # tracking branch git branch -u origin/serverfix git branch --set-upstream-to origin/serverfix # delete local branch git branch -d mbl/test # delete remote branch git push origin --delete mbl/test # fetch with delete remote links git fetch -p git reflog show git log --oneline # fixup git commit --fixup fb2f677 git fetch origin git rebase -i --autosquash origin/master git push -f origin mbl/first-touch # prepsani hlasek a podobne git rebase -i origin/master # revert git add git reset # undo last commit git reset --soft HEAD~1 # unstage git reset HEAD # reset to master git reset --hard origin/master ---------------------------------------------------------- git rebase -i -origin/master # u daneho commitu nastavit "edit" # reset na predeslou verzi git reset HEAD^ # proved veskere dilci commity git rebase --continue # pouzije comment z jineho commitu commit -pc ```