convert to bare
mv .git/ ../repo.git/ cd ../repo.git/ git config --bool core.bare true
convert to normal
git config --local --bool core.bare false
show last commits
#git show #git log -10 --oneline #git log -10 --pretty=oneline git log -10 --pretty=format:"%h - %an, %ar : %s" #git log -10 --pretty=%B git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" git lg -10
with diffs
git log -p
query the local repository
git reflog git reflog -1 | sed 's/^.*: //'
re-fetch a single file
git fetch git checkout origin/master -- folder/file
re-fetch everything
git fetch git reset --hard origin/master
git reset
git checkout HEAD folder/file
if you forgot to identify yourself,
git commit --amend --reset-author
otherwise if you need to fix e.g. a typo,
git commit --amend
and in case you already pushed it before,
git push --force
undo last commit
git reset HEAD^
–or– undo last commit and also undo the changes in the code
git reset --hard HEAD^
undo a previous commit – go back to the parent of the offending commit,
git rebase -i 03e6c6f^ REMOVE THE OFFENDING COMMITS FROM THE LIST
in case you pushed it already, eventually undo the corresponding push – but this is not practical at all – do not do that – unless you are alone on the project, or you team is really small
git push -f
because the other users or possibly your own other systems may re-sync by doing
git pull --rebase
git log #git reflog git reset --hard COMMIT-ID
git log --reverse --oneline --pretty=format:"%h - %an, %ar : %s" | head -10 git rebase -i 953b5a2^ git push -f
git pull origin master
and check
git log -p -20
Changing a commit message https://help.github.com/articles/changing-a-commit-message/
Git HowTo: revert a commit already pushed to a remote repository http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html
On undoing, fixing, or removing commits in git https://sethrobertson.github.io/GitFixUm/fixup.html
2.4 Git Basics - Undoing Things https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things
How do I navigate to the earliest commit in a Github repository? https://stackoverflow.com/questions/28533602/how-do-i-navigate-to-the-earliest-commit-in-a-github-repository
Graphs in GIT https://paquier.xyz/linux-2/graphs-in-git/
to bare https://stackoverflow.com/questions/2199897/how-to-convert-a-normal-git-repository-to-a-bare-one
https://stackoverflow.com/questions/7293008/how-to-read-last-commit-comment
https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History
https://til.hashrocket.com/posts/8ii3emcrda-show-file-diffs-when-viewing-git-log
Re-fetch a single file https://stackoverflow.com/questions/28375418/how-to-pull-a-single-file-from-a-server-repository-in-git
Re-fetch everything https://stackoverflow.com/questions/3949804/force-overwrite-of-local-file-with-whats-it-origin-repo
How do I undo ‘git add’ before commit? https://stackoverflow.com/questions/348170/how-do-i-undo-git-add-before-commit
Restoring deleted files in Git https://www.git-tower.com/learn/git/faq/restoring-deleted-files
Git: cannot checkout branch - error: pathspec ‘…’ did not match any file(s) known to git https://stackoverflow.com/questions/5989592/git-cannot-checkout-branch-error-pathspec-did-not-match-any-files-kn
https://help.github.com/en/articles/changing-a-commit-message
https://gist.github.com/nepsilon/156387acf9e1e72d48fa35c4fabef0b4
Fatal: Not possible to fast-forward, aborting https://stackoverflow.com/questions/13106179/fatal-not-possible-to-fast-forward-aborting ==> git pull –no-ff
How can I see the changes in a Git commit? https://stackoverflow.com/questions/17563726/how-to-see-the-changes-in-a-git-commit
https://stackoverflow.com/questions/13106179/error-fatal-not-possible-to-fast-forward-aborting –> –no-ff