Installation
To install git for the current user, run:
Graphical front-ends
Configuration
Usage
Creating a Git repository
To create a new git repository, in the current directory, do:
A message should confirm the creation of the repository:
Initialized empty Git repository in /root/test/.git/
Getting a Git repository
To clone an existing git repository, do:
$ git clone https://github.com/MunGell/awesome-for-beginners.git
This will create a new folder awesome-for-beginners
. To go to the new folder:
$ cd awesome-for-beginners
Recording changes
After you’ve made some changes, commit them to the git repository, to permanently save the current version.
Staging changes
To add all changed, files to the commit, do:
To add individual, changed files to the commit, do:
To see all files, that will be added to the commit, do:
If you like to clear the staging area, and start again, do:
Committing changes
To commit the changes you’ve made, make sure that you’ve added them to the staging area with git add .
and reviewed all changes with git status
. Now go ahead, and commit (save) the changes:
$ git commit -m "file: revised instructions"
It’s good practice, to add short but clear commit messages.
Tips and tricks
Using multiple SSH keys
Create ~/.ssh/config
and define all domains, and keys you’d like to use.
host git.domain1.com
HostName git.domain1.com
IdentityFile ~/.ssh/key1
User git
host git.domain2.com
HostName git.domain2.com
IdentityFile ~/.ssh/key2
User git
Troubleshooting
Error: gpg failed to sign the data
If you’re facing issues signing with gpg, here’s what you can do:
$ git commit -m "initial commit"
error: gpg failed to sign the data
fatal: failed to write commit object
Double-check that gpg is working:
$ echo "test" | gpg --clearsign
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
test
gpg: signing failed: No pinentry
gpg: [stdin]: clear-sign failed: No pinentry
Note: It’s not working; Looks like it cannot find pinentry.
Quick Fix
Find out the location of pinentry:
# Find out pinentry location
$ which pinentry
/run/current-system/profile/bin/pinentry
Stop the running gpg daemon:
# kill running daemon
pkill gpg-agent
Start daemon:
# run new daemon
gpg-agent --pinentry-program=/run/current-system/profile/bin/pinentry --daemon
See also