====== GIT ======
====== Preparation ======
===== bash completion =====
[[https://git-scm.com/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Bash|A1.6 Appendix A: Git in Other Environments - Git in Bash]]
Package ''git'' contains:
/etc/bash_completion.d/git-prompt
/usr/share/bash-completion/completions/git
/usr/share/bash-completion/completions/gitk
. /usr/share/bash-completion/completions/git
. /usr/lib/git-core/git-sh-prompt
if [ "$color_prompt" = yes ]; then
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 "(%s)")\[\033[00m\]\$ '
else
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\'$(__git_ps1 "(%s)")'\$ '
fi
=== git-email ===
sudo apt-get install git-email
git config sendemail.signedoffcc false
git config sendemail.suppressfrom true
=== replace github's git: links ===
NOTE: Github was disabled git protocol. So only ''https:'' or ssh ''git@'' is valid.
git config --global url.https://github.com/daurnimator/lua-systemd.insteadOf git://github.com/daurnimator/lua-systemd
# or
git config --global url.https://.insteadOf git://
Keywords: git protocol, ''git:'' protocol
=== replace github https links ===
git config --global url.git@github.com:.insteadOf https://github.com/
====== Import HG (mercurial) repo ======
sudo apt-get install hg-fast-export
git init
hg-fast-export -r .
====== Usage ======
==== fetch moved tags ====
git fetch origin --tags --force
==== Undo a commit ====
Undo a commit and redo
$ git commit ...
$ git reset --soft HEAD~1
<< edit files as necessary >>
$ git add ....
$ git commit -c ORIG_HEAD
==== Local copy of one branch from public repo ====
git remote add ti git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git
git remote add tilocal /home/user/mirrors/ti-linux-kernel
git fetch ti refs/heads/ti-linux-3.14.y
git checkout ti-linux-3.14.y
Now we have latest version from ti-linux-3.14.y branch.
Add our local GitLab server
git remote add gitlab ssh://path...
And push current branch (we are on ti-linux-3.14.y after checkout)
git push -u gitlab
==== repo clean and repack ====
git reflog expire --expire=1.minute refs/heads/master
git fsck --unreachable
git prune
git gc
====== Debug ======
GIT_TRACE=1 git clone ...
GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone ...