Git - mwicat/personal GitHub Wiki
Show branches tree
sudo apt install git-extras
git-show-tree
Fetch remote branch
git fetch
git checkout test
git fetch origin branch1:branch1
Clean repository
git clean -fdx
Cancel commit
git commit --amend
Change most recent commit message
git commit --amend -m "New commit message."
git push --force
Change messages of 5 last commits
https://linuxize.com/post/change-git-commit-message/#changing-an-older-or-multiple-commits
git rebase -i HEAD~5
git push --force
Undo commit
git reset --soft HEAD~1
Remove remote commit
git rebase -i HEAD~2
git push origin +master
Undelete file
git rev-list -n 1 HEAD -- "$file"
git checkout <deleting_commit>^ -- "$file"
Get previous version of file
git show HEAD~1:filelocation
Unstage file
git reset HEAD path/to/file
Add to github
git remote add origin [email protected]:mwicat/repo.git
git push origin master
Show unpushed commits
git log @{push}..
git log origin/master..HEAD --stat
git diff origin/master..HEAD
Git remove untracked files
check
git clean -n
force
git clean -f
Conflict get ours/theirs
git checkout --ours -- FILE
git checkout --theirs -- FILE
Sort branches by dates
git branch --sort=committerdate
global .gitignore
git config --global core.excludesfile ~/.gitignore
.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# PyCharm
.idea/