Version 10 (modified by techene, 3 years ago) (diff) |
---|
Une métaphore amusante consiste à considérer Git comme un utilitaire de gestion des chronologies.
Where am I ? Bash hint !
parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
Useful links
https://git-scm.com/docs/git-commit
https://www.atlassian.com/fr/git/tutorials/undoing-changes
https://githowto.com/getting_old_versions
Useful commands
git-restore
git restore deleted_file.F90 Restore working tree files git restore --source MY_BRANCH~2 file_before_last_2_commit.F90 https://git-scm.com/docs/git-restore
git-branch
git branch -D MY_BRANCH - Delete locally Deleted branch debug_rk3 (was 63a26b2). git checkout -b debug_rk3 63a26b2 - Retrieve the branch deleted
git-reset
git reset #sha - come back to former state of the branch useful when you want to cancel a commit
git-checkout ???
git checkout MY_BRANCH - Switch branches [deprecated] git checkout old_commited_files.F90 restore working tree file [deprecated] https://git-scm.com/docs/git-checkout
Process
git stash emacs file.F90 git add file.F90 git commit -m 'comment' git status git diff dev_2021_rk3 remotes/origin/dev_2021_rk3 git push
Create a branch post commit
git clone xxx git switch main emacs files.F90 git add file.F90 git commit -m 'comments' git log git checkout #sha git branch MY_BRANCH git switch MY_BRANCH git merge main (modified) git push --set-upstream origin MY_BRANCH