git


Git is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source-code management in software development, but it can be used to keep track of changes in any set of files. As a distributed revision-control system, it is aimed at speed, data integrity, and support for distributed, non-linear workflows.

Wikipedia


Installation

To install git for the current user, run:

$ guix package -i git

Graphical front-ends

Configuration

Usage

Creating a Git repository

To create a new git repository, in the current directory, do:

$ git init

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:

$ git add .

To add individual, changed files to the commit, do:

$ git add file-name

To see all files, that will be added to the commit, do:

$ git status

If you like to clear the staging area, and start again, do:

$ git reset
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

PantherX & (unofficial) GNU Guix Wiki.

Last update: 2024-04-21 10:28:03 +0000 | Apache-2.0

Inspired by the excellent Arch Linux Wiki