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.

Revision selection
Viewing changes

Undoing things

Branching

Collaboration

Pull requests
Using remotes
Push to a repository
Dealing with merges

History and versioning

Searching the history
Tagging
Organizing commits


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

Using git-config

Adopting a good etiquette

Speeding up authentication

Protocol defaults

Bash completion

Git prompt

Visual representation

Commit tips

Signing commits

Working with a non-master branch

Directly sending patches to a mailing list

When the remote repo is huge

Simplest way: fetch the entire repo
Partial fetch
Get other branches
Possible Future alternative

See also

PantherX & (unofficial) GNU Guix Wiki.

Last update: 2023-02-03 19:33:34 +0000 | Apache-2.0

Inspired by the excellent Arch Linux Wiki