git
Installation
sudo apt install git
git --version
Configuration
git config --global user.name "Your Name"
git config --global user.email "your.name@domain.com"
git config -l --global
Use Credential Managers
1. Default Credential Manager
git config --global credential.helper store
The next time you’ll try to pull
or push
from a repository that require authentication, git will prompt you for your username and password. git-credential-store
will securely store these credentials in plain text on your local machine (typically in ~/.git-credentials
). Subsequent Git operations will automatically use these stored credentials without prompting you again.
2. Alternative Credential Helpers (More Secure Options):
For enhanced security, consider using other credential helpers that integrate with your system’s secure storage:
git-credential-libsecret
: Uses the Secret Service API (often implemented by GNOME Keyring or KDE KWallet) to store credentials securely. You’ll need to installlibsecret-1-dev
andgit-credential-libsecret
. Then configure it:
sudo apt-get update
sudo apt-get install libsecret-1-dev git-credential-libsecret
git config --global credential.helper libsecret
Debian does not package it, see https://pkgs.org/search/?q=git-credential-libsecret, and we have to build it:
sudo apt install libsecret-1-0 libsecret-1-dev libglib2.0-dev
sudo apt install make build-essential
sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
git-credential-osxkeychain
(if you were on macOS): Uses the macOS Keychain.
[^] https://git-scm.com/doc/credential-helpers
clean activity history
$ git gc --aggressive --prune=all
Enumerating objects: 1605, done.
Counting objects: 100% (1605/1605), done.
Delta compression using up to 16 threads
Compressing objects: 100% (1441/1441), done.
Writing objects: 100% (1605/1605), done.
Total 1605 (delta 725), reused 113 (delta 0), pack-reused 0
Removing duplicate objects: 100% (256/256), done.
$ git push -f origin main
Everything up-to-date
Remove the latest commit
git reset --hard HEAD^
Rebase with master
Ensure your master branch is up to date:
git checkout master
git pull origin master
Switch back to your current branch:
git checkout <your-branch>
Rebase your current branch onto master:
git rebase master
During the rebase process, Git will replay your commits on top of the latest commits from the master branch. If there are any conflicts, Git will pause and allow you to resolve them. After resolving conflicts, you can continue the rebase with:
git rebase --continue
If you want to abort the rebase process at any point, you can use:
git rebase --abort
This will return your branch to its original state before the rebase started.
git push origin --force