giteveryday

title: giteveryday(7)

text:
# giteveryday(7)

## NAME
giteveryday - A useful minimum set of commands for Everyday Git

## SYNOPSIS
Everyday Git With 20 Commands Or So

## DESCRIPTION
Git users can broadly be grouped into four categories for the purposes of describing here a small set of useful commands for everyday Git.

•Individual Developer (Standalone) commands are essential for anybody who makes a commit, even for somebody who works alone.

•If you work with other people, you will need commands listed in the Individual Developer (Participant) section as well.

•People who play the Integrator role need to learn some more commands in addition to the above.

•Repository Administration commands are for system administrators who are responsible for the care and feeding of Git repositories.

## INDIVIDUAL DEVELOPER (STANDALONE)
A standalone individual developer does not exchange patches with other people, and works alone in a single repository, using the following commands.

•git-init(1) to create a new repository.

•git-log(1) to see what happened.

•git-switch(1) and git-branch(1) to switch branches.

•git-add(1) to manage the index file.

•git-diff(1) and git-status(1) to see what you are in the middle of doing.

•git-commit(1) to advance the current branch.

•git-restore(1) to undo changes.

•git-merge(1) to merge between local branches.

•git-rebase(1) to maintain topic branches.

•git-tag(1) to mark a known point.

### Examples
Use a tarball as a starting point for a new repository.

```
$ tar zxf frotz.tar.gz
$ cd frotz
$ git init
$ git add . (1)
$ git commit -m "import of frotz source tree."
$ git tag v2.43 (2)
```

1.

add everything under the current directory.

2.

make a lightweight, unannotated tag.

Create a topic branch and develop.

```
$ git switch -c alsa-audio (1)
$ edit/compile/test
$ git restore curses/ux_audio_oss.c (2)
$ git add curses/ux_audio_alsa.c (3)
$ edit/compile/test
$ git diff HEAD (4)
$ git commit -a -s (5)
$ edit/compile/test
$ git diff HEAD^ (6)
$ git commit -a --amend (7)
$ git switch master (8)
$ git merge alsa-audio (9)
$ git log --since='3 days ago' (10)
$ git log v2.43.. curses/ (11)
```

1.

create a new topic branch.

2.

revert your botched changes in curses/ux_audio_oss.c.

3.

you need to tell Git if you added a new file; removal and modification will be caught if you do git commit -a later.

4.

to see what changes you are committing.

5.

commit everything, as you have tested, with your sign-off.

6.

look at all your changes including the previous commit.

7.

amend the previous commit, adding all your new changes, using your original message.

8.

switch to the master branch.

9.

merge a topic branch into your master branch.

10.

review commit logs; other forms to limit output can be combined and include -10 (to show up to 10 commits), --until=2005-12-10, etc.

11.

view only the changes that touch what’s in curses/ directory, since v2.43 tag.

## INDIVIDUAL DEVELOPER (PARTICIPANT)
A developer working as a participant in a group project needs to learn how to communicate with others, and uses these commands in addition to the ones needed by a standalone developer.

•git-clone(1) from the upstream to prime your local repository.

•git-pull(1) and git-fetch(1) from "origin" to keep up-to-date with the upstream.

•git-push(1) to shared repository, if you adopt CVS style shared repository workflow.

•git-format-patch(1) to prepare e-mail submission, if you adopt Linux kernel-style public forum workflow.

•git-send-email(1) to send your e-mail submission without corruption by your MUA.

•git-request-pull(1) to create a summary of changes for your upstream to pull.

### Examples
Clone the upstream and work on it. Feed changes to upstream.

```
$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
$ cd my2.6
$ git switch -c mine master (1)
$ edit/compile/test; git commit -a -s (2)
$ git format-patch master (3)
$ git send-email --to="person <email@example.com>" 00*.patch (4)
$ git switch master (5)
$ git pull (6)
$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 (7)
$ git ls-remote --heads http://git.kernel.org/.../jgarzik/libata-dev.git (8)
$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL (9)
$ git reset --hard ORIG_HEAD (10)
$ git gc (11)
```

1.

checkout a new branch mine from master.

2.

repeat as needed.

3.

extract patches from your branch, relative to master,

4.

and email them.

5.

return to master, ready to see what’s new

6.

git pull fetches from origin by default and merges into the current branch.

7.

immediately after pulling, look at the changes done upstream since last time we checked, only in the area we are interested in.

8.

check the branch names in an external repository (if not known).

9.

fetch from a specific branch ALL from a specific repository and merge it.

10.

revert the pull.

11.

garbage collect leftover objects from reverted pull.

Push into another repository.

```
satellite$ git clone mothership:frotz frotz (1)
satellite$ cd frotz
satellite$ git config --get-regexp '^(remote|branch)\.' (2)
remote.origin.url mothership:frotz
remote.origin.fetch refs/heads/*:refs/remotes/origin/*
branch.master.remote origin
branch.master.merge refs/heads/master
satellite$ git config remote.origin.push \

           +refs/heads/*:refs/remotes/satellite/* (3)
satellite$ edit/compile/test/commit
satellite$ git push origin (4)
mothership$ cd frotz
mothership$ git switch master
mothership$ git merge satellite/master (5)
```

1.

mothership machine has a frotz repository under your home directory; clone from it to start a repository on the satellite machine.

2.

clone sets these configuration variables by default. It arranges git pull to fetch and store the branches of mothership machine to local remotes/origin/* remote-tracking branches.

3.

arrange git push to push all local branches to their corresponding branch of the mothership machine.

4.

push will stash all our work away on remotes/satellite/* remote-tracking branches on the mothership machine. You could use this as a back-up method. Likewise, you can pretend that mothership "fetched" from you (useful when access is one sided).

5.

on mothership machine, merge the work done on the satellite machine into the master branch.

Branch off of a specific tag.

```
$ git switch -c private2.6.14 v2.6.14 (1)
$ edit/compile/test; git commit -a
$ git checkout master
$ git cherry-pick v2.6.14..private2.6.14 (2)
```

1.

create a private branch based on a well known (but somewhat behind) tag.

2.

forward port all changes in private2.6.14 branch to master branch without a formal "merging". Or longhand git format-patch -k -m --stdout v2.6.14..private2.6.14 | git am -3 -k

An alternate participant submission mechanism is using the git request-pull or pull-request mechanisms (e.g. as used on GitHub (www.github.com) to notify your upstream of your contribution.

## INTEGRATOR
A fairly central person acting as the integrator in a group project receives changes made by others, reviews and integrates them and publishes the result for others to use, using these commands in addition to the ones needed by participants.

This section can also be used by those who respond to git request-pull or pull-request on GitHub (www.github.com) to integrate the work of others into their history. A sub-area lieutenant for a repository will act both as a participant and as an integrator.

•git-am(1) to apply patches e-mailed in from your contributors.

•git-pull(1) to merge from your trusted lieutenants.

•git-format-patch(1) to prepare and send suggested alternative to contributors.

•git-revert(1) to undo botched commits.

•git-push(1) to publish the bleeding edge.

### Examples
A typical integrator’s Git day.

```
$ git status (1)
$ git branch --no-merged master (2)
$ mailx (3)
& s 2 3 4 5 ./+to-apply
& s 7 8 ./+hold-linus
& q
$ git switch -c topic/one master
$ git am -3 -i -s ./+to-apply (4)
$ compile/test
$ git switch -c hold/linus && git am -3 -i -s ./+hold-linus (5)
$ git switch topic/one && git rebase master (6)
$ git switch -C seen next (7)
$ git merge topic/one topic/two && git merge hold/linus (8)
$ git switch maint
$ git cherry-pick master~4 (9)
$ compile/test
$ git tag -s -m "GIT 0.99.9x" v0.99.9x (10)
$ git fetch ko && for branch in master maint next seen (11)

    do

        git show-branch ko/$branch $branch (12)

    done
$ git push --follow-tags ko (13)
```

1.

see what you were in the middle of doing, if anything.

2.

see which branches haven’t been merged into master yet. Likewise for any other integration branches e.g. maint, next and seen.

3.

read mails, save ones that are applicable, and save others that are not quite ready (other mail readers are available).

4.

apply them, interactively, with your sign-offs.

5.

create topic branch as needed and apply, again with sign-offs.

6.

rebase internal topic branch that has not been merged to the master or exposed as a part of a stable branch.

7.

restart seen every time from the next.

8.

and bundle topic branches still cooking.

9.

backport a critical fix.

10.

create a signed tag.

11.

make sure master was not accidentally rewound beyond that already pushed out.

12.

In the output from git show-branch, master should have everything ko/master has, and next should have everything ko/next has, etc.

13.

push out the bleeding edge, together with new tags that point into the pushed history.

In this example, the ko shorthand points at the Git maintainer’s repository at kernel.org, and looks like this:

```
(in .git/config)
[remote "ko"]

        url = kernel.org:/pub/scm/git/git.git

        fetch = refs/heads/*:refs/remotes/ko/*

        push = refs/heads/master

        push = refs/heads/next

        push = +refs/heads/seen

        push = refs/heads/maint
```

## REPOSITORY ADMINISTRATION
A repository administrator uses the following tools to set up and maintain access to the repository by developers.

•git-daemon(1) to allow anonymous download from repository.

•git-shell(1) can be used as a restricted login shell for shared central repository users.

•git-http-backend(1) provides a server side implementation of Git-over-HTTP ("Smart http") allowing both fetch and push services.

•gitweb(1) provides a web front-end to Git repositories, which can be set-up using the git-instaweb(1) script.

update hook howto[1] has a good example of managing a shared central repository.

In addition there are a number of other widely deployed hosting, browsing and reviewing solutions such as:

•gitolite, gerrit code review, cgit and others.

### Examples
We assume the following in /etc/services

```
$ grep 9418 /etc/services
git             9418/tcp                # Git Version Control System
```

Run git-daemon to serve /pub/scm from inetd.

```
$ grep git /etc/inetd.conf
git     stream  tcp     nowait  nobody \

  /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm
```

The actual configuration line should be on one line.

Run git-daemon to serve /pub/scm from xinetd.

```
$ cat /etc/xinetd.d/git-daemon
# default: off
# description: The Git server offers access to Git repositories
service git
{

        disable = no

        type            = UNLISTED

        port            = 9418

        socket_type     = stream

        wait            = no

        user            = nobody

        server          = /usr/bin/git-daemon

        server_args     = --inetd --export-all --base-path=/pub/scm

        log_on_failure  += USERID
}
```

Check your xinetd(8) documentation and setup, this is from a Fedora system. Others might be different.

Give push/pull only access to developers using git-over-ssh.

e.g. those using: $ git push/pull ssh://host.xz/pub/scm/project

```
$ grep git /etc/passwd (1)
alice:x:1000:1000::/home/alice:/usr/bin/git-shell
bob:x:1001:1001::/home/bob:/usr/bin/git-shell
cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
david:x:1003:1003::/home/david:/usr/bin/git-shell
$ grep git /etc/shells (2)
/usr/bin/git-shell
```

1.

log-in shell is set to /usr/bin/git-shell, which does not allow anything but git push and git pull. The users require ssh access to the machine.

2.

in many distributions /etc/shells needs to list what is used as the login shell.

CVS-style shared repository.

```
$ grep git /etc/group (1)
git:x:9418:alice,bob,cindy,david
$ cd /home/devo.git
$ ls -l (2)

  lrwxrwxrwx   1 david git    17 Dec  4 22:40 HEAD -> refs/heads/master

  drwxrwsr-x   2 david git  4096 Dec  4 22:40 branches

  -rw-rw-r--   1 david git    84 Dec  4 22:40 config

  -rw-rw-r--   1 david git    58 Dec  4 22:40 description

  drwxrwsr-x   2 david git  4096 Dec  4 22:40 hooks

  -rw-rw-r--   1 david git 37504 Dec  4 22:40 index

  drwxrwsr-x   2 david git  4096 Dec  4 22:40 info

  drwxrwsr-x   4 david git  4096 Dec  4 22:40 objects

  drwxrwsr-x   4 david git  4096 Nov  7 14:58 refs

  drwxrwsr-x   2 david git  4096 Dec  4 22:40 remotes
$ ls -l hooks/update (3)

  -r-xr-xr-x   1 david git  3536 Dec  4 22:40 update
$ cat info/allowed-users (4)
refs/heads/master       alice\|cindy
refs/heads/doc-update   bob
refs/tags/v[0-9]*       david
```

1.

place the developers into the same git group.

2.

and make the shared repository writable by the group.

3.

use update-hook example by Carl from Documentation/howto/ for branch policy control.

4.

alice and cindy can push into master, only bob can push into doc-update. david is the release manager and is the only person who can create and push version tags.

## GIT
Part of the git(1) suite

## NOTES
1.

update hook howto

file:///usr/share/doc/git/howto/update-hook-example.html


gitfaq

package: git-core

title: gitfaq(7)

text:
# gitfaq(7)

## NAME
gitfaq - Frequently asked questions about using Git

## SYNOPSIS
gitfaq

## DESCRIPTION
The examples in this FAQ assume a standard POSIX shell, like bash or dash, and a user, A U Thor, who has the account author on the hosting provider git.example.org.

## CONFIGURATION
What should I put in user.name?

You should put your personal name, generally a form using a given name and family name. For example, the current maintainer of Git uses "Junio C Hamano". This will be the name portion that is stored in every commit you make. This configuration doesn’t have any effect on authenticating to remote services; for that, see credential.username in git-config(1).

What does http.postBuffer really do?

This option changes the size of the buffer that Git uses when pushing data to a remote over HTTP or HTTPS. If the data is larger than this size, libcurl, which handles the HTTP support for Git, will use chunked transfer encoding since it isn’t known ahead of time what the size of the pushed data will be. Leaving this value at the default size is fine unless you know that either the remote server or a proxy in the middle doesn’t support HTTP/1.1 (which introduced the chunked transfer encoding) or is known to be broken with chunked data. This is often (erroneously) suggested as a solution for generic push problems, but since almost every server and proxy supports at least HTTP/1.1, raising this value usually doesn’t solve most push problems. A server or proxy that didn’t correctly support HTTP/1.1 and chunked transfer encoding wouldn’t be that useful on the Internet today, since it would break lots of traffic.

Note that increasing this value will increase the memory used on every relevant push that Git does over HTTP or HTTPS, since the entire buffer is allocated regardless of whether or not it is all used. Thus, it’s best to leave it at the default unless you are sure you need a different value.

How do I configure a different editor?

If you haven’t specified an editor specifically for Git, it will by default use the editor you’ve configured using the VISUAL or EDITOR environment variables, or if neither is specified, the system default (which is usually vi). Since some people find vi difficult to use or prefer a different editor, it may be desirable to change the editor used. If you want to configure a general editor for most programs which need one, you can edit your shell configuration (e.g., ~/.bashrc or ~/.zshenv) to contain a line setting the EDITOR or VISUAL environment variable to an appropriate value. For example, if you prefer the editor nano, then you could write the following:

```
export VISUAL=nano
```

If you want to configure an editor specifically for Git, you can either set the core.editor configuration value or the GIT_EDITOR environment variable. You can see git-var(1) for details on the order in which these options are consulted.

Note that in all cases, the editor value will be passed to the shell, so any arguments containing spaces should be appropriately quoted. Additionally, if your editor normally detaches from the terminal when invoked, you should specify it with an argument that makes it not do that, or else Git will not see any changes. An example of a configuration addressing both of these issues on Windows would be the configuration "C:\Program Files\Vim\gvim.exe" --nofork, which quotes the filename with spaces and specifies the --nofork option to avoid backgrounding the process.

## CREDENTIALS
How do I specify my credentials when pushing over HTTP?

The easiest way to do this is to use a credential helper via the credential.helper configuration. Most systems provide a standard choice to integrate with the system credential manager. For example, Git for Windows provides the wincred credential manager, macOS has the osxkeychain credential manager, and Unix systems with a standard desktop environment can use the libsecret credential manager. All of these store credentials in an encrypted store to keep your passwords or tokens secure. In addition, you can use the store credential manager which stores in a file in your home directory, or the cache credential manager, which does not permanently store your credentials, but does prevent you from being prompted for them for a certain period of time.

You can also just enter your password when prompted. While it is possible to place the password (which must be percent-encoded) in the URL, this is not particularly secure and can lead to accidental exposure of credentials, so it is not recommended.

How do I read a password or token from an environment variable?

The credential.helper configuration option can also take an arbitrary shell command that produces the credential protocol on standard output. This is useful when passing credentials into a container, for example. Such a shell command can be specified by starting the option value with an exclamation point. If your password or token were stored in the GIT_TOKEN, you could run the following command to set your credential helper:

```
$ git config credential.helper \

        '!f() { echo username=author; echo "password=$GIT_TOKEN"; };f'
```

How do I change the password or token I’ve saved in my credential manager?

Usually, if the password or token is invalid, Git will erase it and prompt for a new one. However, there are times when this doesn’t always happen. To change the password or token, you can erase the existing credentials and then Git will prompt for new ones. To erase credentials, use a syntax like the following (substituting your username and the hostname):

```
$ echo url=https://author@git.example.org | git credential reject
```

How do I use multiple accounts with the same hosting provider using HTTP?

Usually the easiest way to distinguish between these accounts is to use the username in the URL. For example, if you have the accounts author and committer on git.example.org, you can use the URLs https://author@git.example.org/org1/project1.git and https://committer@git.example.org/org2/project2.git. This way, when you use a credential helper, it will automatically try to look up the correct credentials for your account. If you already have a remote set up, you can change the URL with something like git remote set-url origin https://author@git.example.org/org1/project1.git (see git-remote(1) for details).

How do I use multiple accounts with the same hosting provider using SSH?

With most hosting providers that support SSH, a single key pair uniquely identifies a user. Therefore, to use multiple accounts, it’s necessary to create a key pair for each account. If you’re using a reasonably modern OpenSSH version, you can create a new key pair with something like ssh-keygen -t ed25519 -f ~/.ssh/id_committer. You can then register the public key (in this case, ~/.ssh/id_committer.pub; note the .pub) with the hosting provider. Most hosting providers use a single SSH account for pushing; that is, all users push to the git account (e.g., git@git.example.org). If that’s the case for your provider, you can set up multiple aliases in SSH to make it clear which key pair to use. For example, you could write something like the following in ~/.ssh/config, substituting the proper private key file:

```
# This is the account for author on git.example.org.
Host example_author

        HostName git.example.org

        User git

        # This is the key pair registered for author with git.example.org.

        IdentityFile ~/.ssh/id_author

        IdentitiesOnly yes
# This is the account for committer on git.example.org.
Host example_committer

        HostName git.example.org

        User git

        # This is the key pair registered for committer with git.example.org.

        IdentityFile ~/.ssh/id_committer

        IdentitiesOnly yes
```

Then, you can adjust your push URL to use git@example_author or git@example_committer instead of git@example.org (e.g., git remote set-url git@example_author:org1/project1.git).

## TRANSFERS
How do I sync a working tree across systems?

First, decide whether you want to do this at all. Git works best when you push or pull your work using the typical git push and git fetch commands and isn’t designed to share a working tree across systems. This is potentially risky and in some cases can cause repository corruption or data loss. Usually, doing so will cause git status to need to re-read every file in the working tree. Additionally, Git’s security model does not permit sharing a working tree across untrusted users, so it is only safe to sync a working tree if it will only be used by a single user across all machines.

It is important not to use a cloud syncing service to sync any portion of a Git repository, since this can cause corruption, such as missing objects, changed or added files, broken refs, and a wide variety of other problems. These services tend to sync file by file on a continuous basis and don’t understand the structure of a Git repository. This is especially bad if they sync the repository in the middle of it being updated, since that is very likely to cause incomplete or partial updates and therefore data loss.

An example of the kind of corruption that can occur is conflicts over the state of refs, such that both sides end up with different commits on a branch that the other doesn’t have. This can result in important objects becoming unreferenced and possibly pruned by git gc, causing data loss.

Therefore, it’s better to push your work to either the other system or a central server using the normal push and pull mechanism. However, this doesn’t always preserve important data, like stashes, so some people prefer to share a working tree across systems.

If you do this, the recommended approach is to use rsync -a --delete-after (ideally with an encrypted connection such as with ssh) on the root of repository. You should ensure several things when you do this:

•If you have additional worktrees or a separate Git directory, they must be synced at the same time as the main working tree and repository.

•You are comfortable with the destination directory being an exact copy of the source directory, deleting any data that is already there.

•The repository (including all worktrees and the Git directory) is in a quiescent state for the duration of the transfer (that is, no operations of any sort are taking place on it, including background operations like git gc and operations invoked by your editor). Be aware that even with these recommendations, syncing in this way has some risk since it bypasses Git’s normal integrity checking for repositories, so having backups is advised. You may also wish to do a git fsck to verify the integrity of your data on the destination system after syncing.

## COMMON ISSUES
I’ve made a mistake in the last commit. How do I change it?

You can make the appropriate change to your working tree, run git add <file> or git rm <file>, as appropriate, to stage it, and then git commit --amend. Your change will be included in the commit, and you’ll be prompted to edit the commit message again; if you wish to use the original message verbatim, you can use the --no-edit option to git commit in addition, or just save and quit when your editor opens.

I’ve made a change with a bug and it’s been included in the main branch. How should I undo it?

The usual way to deal with this is to use git revert. This preserves the history that the original change was made and was a valuable contribution, but also introduces a new commit that undoes those changes because the original had a problem. The commit message of the revert indicates the commit which was reverted and is usually edited to include an explanation as to why the revert was made.

How do I ignore changes to a tracked file?

Git doesn’t provide a way to do this. The reason is that if Git needs to overwrite this file, such as during a checkout, it doesn’t know whether the changes to the file are precious and should be kept, or whether they are irrelevant and can safely be destroyed. Therefore, it has to take the safe route and always preserve them. It’s tempting to try to use certain features of git update-index, namely the assume-unchanged and skip-worktree bits, but these don’t work properly for this purpose and shouldn’t be used this way.

If your goal is to modify a configuration file, it can often be helpful to have a file checked into the repository which is a template or set of defaults which can then be copied alongside and modified as appropriate. This second, modified file is usually ignored to prevent accidentally committing it.

I asked Git to ignore various files, yet they are still tracked

A gitignore file ensures that certain file(s) which are not tracked by Git remain untracked. However, sometimes particular file(s) may have been tracked before adding them into the .gitignore, hence they still remain tracked. To untrack and ignore files/patterns, use git rm --cached <file/pattern> and add a pattern to .gitignore that matches the <file>. See gitignore(5) for details.

How do I know if I want to do a fetch or a pull?

A fetch stores a copy of the latest changes from the remote repository, without modifying the working tree or current branch. You can then at your leisure inspect, merge, rebase on top of, or ignore the upstream changes. A pull consists of a fetch followed immediately by either a merge or rebase. See git-pull(1).

Can I use a proxy with Git?

Yes, Git supports the use of proxies. Git honors the standard http_proxy, https_proxy, and no_proxy environment variables commonly used on Unix, and it also can be configured with http.proxy and similar options for HTTPS (see git-config(1)). The http.proxy and related options can be customized on a per-URL pattern basis. In addition, Git can in theory function normally with transparent proxies that exist on the network. For SSH, Git can support a proxy using OpenSSH’s ProxyCommand. Commonly used tools include netcat and socat. However, they must be configured not to exit when seeing EOF on standard input, which usually means that netcat will require -q and socat will require a timeout with something like -t 10. This is required because the way the Git SSH server knows that no more requests will be made is an EOF on standard input, but when that happens, the server may not have yet processed the final request, so dropping the connection at that point would interrupt that request.

An example configuration entry in ~/.ssh/config with an HTTP proxy might look like this:

```
Host git.example.org

    User git

    ProxyCommand socat -t 10 - PROXY:proxy.example.org:%h:%p,proxyport=8080
```

Note that in all cases, for Git to work properly, the proxy must be completely transparent. The proxy cannot modify, tamper with, or buffer the connection in any way, or Git will almost certainly fail to work. Note that many proxies, including many TLS middleboxes, Windows antivirus and firewall programs other than Windows Defender and Windows Firewall, and filtering proxies fail to meet this standard, and as a result end up breaking Git. Because of the many reports of problems and their poor security history, we recommend against the use of these classes of software and devices.

## MERGING AND REBASING
What kinds of problems can occur when merging long-lived branches with squash merges?

In general, there are a variety of problems that can occur when using squash merges to merge two branches multiple times. These can include seeing extra commits in git log output, with a GUI, or when using the ... notation to express a range, as well as the possibility of needing to re-resolve conflicts again and again. When Git does a normal merge between two branches, it considers exactly three points: the two branches and a third commit, called the merge base, which is usually the common ancestor of the commits. The result of the merge is the sum of the changes between the merge base and each head. When you merge two branches with a regular merge commit, this results in a new commit which will end up as a merge base when they’re merged again, because there is now a new common ancestor. Git doesn’t have to consider changes that occurred before the merge base, so you don’t have to re-resolve any conflicts you resolved before.

When you perform a squash merge, a merge commit isn’t created; instead, the changes from one side are applied as a regular commit to the other side. This means that the merge base for these branches won’t have changed, and so when Git goes to perform its next merge, it considers all of the changes that it considered the last time plus the new changes. That means any conflicts may need to be re-resolved. Similarly, anything using the ... notation in git diff, git log, or a GUI will result in showing all of the changes since the original merge base.

As a consequence, if you want to merge two long-lived branches repeatedly, it’s best to always use a regular merge commit.

If I make a change on two branches but revert it on one, why does the merge of those branches include the change?

By default, when Git does a merge, it uses a strategy called the ort strategy, which does a fancy three-way merge. In such a case, when Git performs the merge, it considers exactly three points: the two heads and a third point, called the merge base, which is usually the common ancestor of those commits. Git does not consider the history or the individual commits that have happened on those branches at all. As a result, if both sides have a change and one side has reverted that change, the result is to include the change. This is because the code has changed on one side and there is no net change on the other, and in this scenario, Git adopts the change.

If this is a problem for you, you can do a rebase instead, rebasing the branch with the revert onto the other branch. A rebase in this scenario will revert the change, because a rebase applies each individual commit, including the revert. Note that rebases rewrite history, so you should avoid rebasing published branches unless you’re sure you’re comfortable with that. See the NOTES section in git-rebase(1) for more details.

## HOOKS
How do I use hooks to prevent users from making certain changes?

The only safe place to make these changes is on the remote repository (i.e., the Git server), usually in the pre-receive hook or in a continuous integration (CI) system. These are the locations in which policy can be enforced effectively. It’s common to try to use pre-commit hooks (or, for commit messages, commit-msg hooks) to check these things, which is great if you’re working as a solo developer and want the tooling to help you. However, using hooks on a developer machine is not effective as a policy control because a user can bypass these hooks with --no-verify without being noticed (among various other ways). Git assumes that the user is in control of their local repositories and doesn’t try to prevent this or tattle on the user.

In addition, some advanced users find pre-commit hooks to be an impediment to workflows that use temporary commits to stage work in progress or that create fixup commits, so it’s better to push these kinds of checks to the server anyway.

## CROSS-PLATFORM ISSUES
I’m on Windows and my text files are detected as binary.

Git works best when you store text files as UTF-8. Many programs on Windows support UTF-8, but some do not and only use the little-endian UTF-16 format, which Git detects as binary. If you can’t use UTF-8 with your programs, you can specify a working tree encoding that indicates which encoding your files should be checked out with, while still storing these files as UTF-8 in the repository. This allows tools like git-diff(1) to work as expected, while still allowing your tools to work. To do so, you can specify a gitattributes(5) pattern with the working-tree-encoding attribute. For example, the following pattern sets all C files to use UTF-16LE-BOM, which is a common encoding on Windows:

```
*.c     working-tree-encoding=UTF-16LE-BOM
```

You will need to run git add --renormalize to have this take effect. Note that if you are making these changes on a project that is used across platforms, you’ll probably want to make it in a per-user configuration file or in the one in $GIT_DIR/info/attributes, since making it in a .gitattributes file in the repository will apply to all users of the repository.

See the following entry for information about normalizing line endings as well, and see gitattributes(5) for more information about attribute files.

I’m on Windows and git diff shows my files as having a ^M at the end.

By default, Git expects files to be stored with Unix line endings. As such, the carriage return (^M) that is part of a Windows line ending is shown because it is considered to be trailing whitespace. Git defaults to showing trailing whitespace only on new lines, not existing ones. You can store the files in the repository with Unix line endings and convert them automatically to your platform’s line endings. To do that, set the configuration option core.eol to native and see the question on recommended storage settings for information about how to configure files as text or binary.

You can also control this behavior with the core.whitespace setting if you don’t wish to remove the carriage returns from your line endings.

Why do I have a file that’s always modified?

Internally, Git always stores file names as sequences of bytes and doesn’t perform any encoding or case folding. However, Windows and macOS by default both perform case folding on file names. As a result, it’s possible to end up with multiple files or directories whose names differ only in case. Git can handle this just fine, but the file system can store only one of these files, so when Git reads the other file to see its contents, it looks modified. It’s best to remove one of the files such that you only have one file. You can do this with commands like the following (assuming two files AFile.txt and afile.txt) on an otherwise clean working tree:

```
$ git rm --cached AFile.txt
$ git commit -m 'Remove files conflicting in case'
$ git checkout .
```

This avoids touching the disk, but removes the additional file. Your project may prefer to adopt a naming convention, such as all-lowercase names, to avoid this problem from occurring again; such a convention can be checked using a pre-receive hook or as part of a continuous integration (CI) system.

It is also possible for perpetually modified files to occur on any platform if a smudge or clean filter is in use on your system but a file was previously committed without running the smudge or clean filter. To fix this, run the following on an otherwise clean working tree:

```
$ git add --renormalize .
```

What’s the recommended way to store files in Git?

While Git can store and handle any file of any type, there are some settings that work better than others. In general, we recommend that text files be stored in UTF-8 without a byte-order mark (BOM) with LF (Unix-style) endings. We also recommend the use of UTF-8 (again, without BOM) in commit messages. These are the settings that work best across platforms and with tools such as git diff and git merge. Additionally, if you have a choice between storage formats that are text based or non-text based, we recommend storing files in the text format and, if necessary, transforming them into the other format. For example, a text-based SQL dump with one record per line will work much better for diffing and merging than an actual database file. Similarly, text-based formats such as Markdown and AsciiDoc will work better than binary formats such as Microsoft Word and PDF.

Similarly, storing binary dependencies (e.g., shared libraries or JAR files) or build products in the repository is generally not recommended. Dependencies and build products are best stored on an artifact or package server with only references, URLs, and hashes stored in the repository.

We also recommend setting a gitattributes(5) file to explicitly mark which files are text and which are binary. If you want Git to guess, you can set the attribute text=auto.

With text files, Git will generally ensure that LF endings are used in the repository. The core.autocrlf and core.eol configuration variables specify what line-ending convention is followed when any text file is checked out. You can also use the eol attribute (e.g., eol=crlf) to override which files get what line-ending treatment.

For example, generally shell files must have LF endings and batch files must have CRLF endings, so the following might be appropriate in some projects:

```
# By default, guess.
*       text=auto
# Mark all C files as text.
*.c     text
# Ensure all shell files have LF endings and all batch files have CRLF
# endings in the working tree and both have LF in the repo.
*.sh text eol=lf
*.bat text eol=crlf
# Mark all JPEG files as binary.
*.jpg   binary
```

These settings help tools pick the right format for output such as patches and result in files being checked out in the appropriate line ending for the platform.

## GIT
Part of the git(1) suite

branch: sisyphus


gitglossary

title: gitglossary(7)

summary: A Git Glossary

text:
# gitglossary(7)

## NAME
gitglossary - A Git Glossary

## SYNOPSIS
*

## DESCRIPTION
alternate object database

Via the alternates mechanism, a repository can inherit part of its object database from another object database, which is called an "alternate".

bare repository

A bare repository is normally an appropriately named directory with a .git suffix that does not have a locally checked-out copy of any of the files under revision control. That is, all of the Git administrative and control files that would normally be present in the hidden .git sub-directory are directly present in the repository.git directory instead, and no other files are present and checked out. Usually publishers of public repositories make bare repositories available.

blob object

Untyped object, e.g. the contents of a file.

branch

A "branch" is a line of development. The most recent commit on a branch is referred to as the tip of that branch. The tip of the branch is referenced by a branch head, which moves forward as additional development is done on the branch. A single Git repository can track an arbitrary number of branches, but your working tree is associated with just one of them (the "current" or "checked out" branch), and HEAD points to that branch.

cache

Obsolete for: index.

chain

A list of objects, where each object in the list contains a reference to its successor (for example, the successor of a commit could be one of its parents).

changeset

BitKeeper/cvsps speak for "commit". Since Git does not store changes, but states, it really does not make sense to use the term "changesets" with Git.

checkout

The action of updating all or part of the working tree with a tree object or blob from the object database, and updating the index and HEAD if the whole working tree has been pointed at a new branch.

cherry-picking

In SCM jargon, "cherry pick" means to choose a subset of changes out of a series of changes (typically commits) and record them as a new series of changes on top of a different codebase. In Git, this is performed by the "git cherry-pick" command to extract the change introduced by an existing commit and to record it based on the tip of the current branch as a new commit.

clean

A working tree is clean, if it corresponds to the revision referenced by the current head. Also see "dirty".

commit

As a noun: A single point in the Git history; the entire history of a project is represented as a set of interrelated commits. The word "commit" is often used by Git in the same places other revision control systems use the words "revision" or "version". Also used as a short hand for commit object. As a verb: The action of storing a new snapshot of the project’s state in the Git history, by creating a new commit representing the current state of the index and advancing HEAD to point at the new commit.

commit graph concept, representations and usage

A synonym for the DAG structure formed by the commits in the object database, referenced by branch tips, using their chain of linked commits. This structure is the definitive commit graph. The graph can be represented in other ways, e.g. the "commit-graph" file.

commit-graph file

The "commit-graph" (normally hyphenated) file is a supplemental representation of the commit graph which accelerates commit graph walks. The "commit-graph" file is stored either in the .git/objects/info directory or in the info directory of an alternate object database.

commit object

An object which contains the information about a particular revision, such as parents, committer, author, date and the tree object which corresponds to the top directory of the stored revision.

commit-ish (also committish)

A commit object or an object that can be recursively dereferenced to a commit object. The following are all commit-ishes: a commit object, a tag object that points to a commit object, a tag object that points to a tag object that points to a commit object, etc.

core Git

Fundamental data structures and utilities of Git. Exposes only limited source code management tools.

DAG

Directed acyclic graph. The commit objects form a directed acyclic graph, because they have parents (directed), and the graph of commit objects is acyclic (there is no chain which begins and ends with the same object).

dangling object

An unreachable object which is not reachable even from other unreachable objects; a dangling object has no references to it from any reference or object in the repository.

dereference

Referring to a symbolic ref: the action of accessing the reference pointed at by a symbolic ref. Recursive dereferencing involves repeating the aforementioned process on the resulting ref until a non-symbolic reference is found. Referring to a tag object: the action of accessing the object a tag points at. Tags are recursively dereferenced by repeating the operation on the result object until the result has either a specified object type (where applicable) or any non-"tag" object type. A synonym for "recursive dereference" in the context of tags is "peel".

Referring to a commit object: the action of accessing the commit’s tree object. Commits cannot be dereferenced recursively.

Unless otherwise specified, "dereferencing" as it used in the context of Git commands or protocols is implicitly recursive.

detached HEAD

Normally the HEAD stores the name of a branch, and commands that operate on the history HEAD represents operate on the history leading to the tip of the branch the HEAD points at. However, Git also allows you to check out an arbitrary commit that isn’t necessarily the tip of any particular branch. The HEAD in such a state is called "detached". Note that commands that operate on the history of the current branch (e.g. git commit to build a new history on top of it) still work while the HEAD is detached. They update the HEAD to point at the tip of the updated history without affecting any branch. Commands that update or inquire information about the current branch (e.g. git branch --set-upstream-to that sets what remote-tracking branch the current branch integrates with) obviously do not work, as there is no (real) current branch to ask about in this state.

directory

The list you get with "ls" :-)

dirty

A working tree is said to be "dirty" if it contains modifications which have not been committed to the current branch.

evil merge

An evil merge is a merge that introduces changes that do not appear in any parent.

fast-forward

A fast-forward is a special type of merge where you have a revision and you are "merging" another branch's changes that happen to be a descendant of what you have. In such a case, you do not make a new merge commit but instead just update your branch to point at the same revision as the branch you are merging. This will happen frequently on a remote-tracking branch of a remote repository.

fetch

Fetching a branch means to get the branch’s head ref from a remote repository, to find out which objects are missing from the local object database, and to get them, too. See also git-fetch(1).

file system

Linus Torvalds originally designed Git to be a user space file system, i.e. the infrastructure to hold files and directories. That ensured the efficiency and speed of Git.

Git archive

Synonym for repository (for arch people).

gitfile

A plain file .git at the root of a working tree that points at the directory that is the real repository. For proper use see git-worktree(1) or git-submodule(1). For syntax see gitrepository-layout(5).

grafts

Grafts enable two otherwise different lines of development to be joined together by recording fake ancestry information for commits. This way you can make Git pretend the set of parents a commit has is different from what was recorded when the commit was created. Configured via the .git/info/grafts file. Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see git-replace(1) for a more flexible and robust system to do the same thing.

hash

In Git’s context, synonym for object name.

head

A named reference to the commit at the tip of a branch. Heads are stored in a file in $GIT_DIR/refs/heads/ directory, except when using packed refs. (See git-pack-refs(1).)

HEAD

The current branch. In more detail: Your working tree is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the heads in your repository, except when using a detached HEAD, in which case it directly references an arbitrary commit.

head ref

A synonym for head.

hook

During the normal execution of several Git commands, call-outs are made to optional scripts that allow a developer to add functionality or checking. Typically, the hooks allow for a command to be pre-verified and potentially aborted, and allow for a post-notification after the operation is done. The hook scripts are found in the $GIT_DIR/hooks/ directory, and are enabled by simply removing the .sample suffix from the filename. In earlier versions of Git you had to make them executable.

index

A collection of files with stat information, whose contents are stored as objects. The index is a stored version of your working tree. Truth be told, it can also contain a second, and even a third version of a working tree, which are used when merging.

index entry

The information regarding a particular file, stored in the index. An index entry can be unmerged, if a merge was started, but not yet finished (i.e. if the index contains multiple versions of that file).

master

The default development branch. Whenever you create a Git repository, a branch named "master" is created, and becomes the active branch. In most cases, this contains the local development, though that is purely by convention and is not required.

merge

As a verb: To bring the contents of another branch (possibly from an external repository) into the current branch. In the case where the merged-in branch is from a different repository, this is done by first fetching the remote branch and then merging the result into the current branch. This combination of fetch and merge operations is called a pull. Merging is performed by an automatic process that identifies changes made since the branches diverged, and then applies all those changes together. In cases where changes conflict, manual intervention may be required to complete the merge. As a noun: unless it is a fast-forward, a successful merge results in the creation of a new commit representing the result of the merge, and having as parents the tips of the merged branches. This commit is referred to as a "merge commit", or sometimes just a "merge".

object

The unit of storage in Git. It is uniquely identified by the SHA-1 of its contents. Consequently, an object cannot be changed.

object database

Stores a set of "objects", and an individual object is identified by its object name. The objects usually live in $GIT_DIR/objects/.

object identifier (oid)

Synonym for object name.

object name

The unique identifier of an object. The object name is usually represented by a 40 character hexadecimal string. Also colloquially called SHA-1.

object type

One of the identifiers "commit", "tree", "tag" or "blob" describing the type of an object.

octopus

To merge more than two branches.

orphan

The act of getting on a branch that does not exist yet (i.e., an unborn branch). After such an operation, the commit first created becomes a commit without a parent, starting a new history.

origin

The default upstream repository. Most projects have at least one upstream project which they track. By default origin is used for that purpose. New upstream updates will be fetched into remote-tracking branches named origin/name-of-upstream-branch, which you can see using git branch -r.

overlay

Only update and add files to the working directory, but don’t delete them, similar to how cp -R would update the contents in the destination directory. This is the default mode in a checkout when checking out files from the index or a tree-ish. In contrast, no-overlay mode also deletes tracked files not present in the source, similar to rsync --delete.

pack

A set of objects which have been compressed into one file (to save space or to transmit them efficiently).

pack index

The list of identifiers, and other information, of the objects in a pack, to assist in efficiently accessing the contents of a pack.

pathspec

Pattern used to limit paths in Git commands. Pathspecs are used on the command line of "git ls-files", "git ls-tree", "git add", "git grep", "git diff", "git checkout", and many other commands to limit the scope of operations to some subset of the tree or working tree. See the documentation of each command for whether paths are relative to the current directory or toplevel. The pathspec syntax is as follows:

•any path matches itself

•the pathspec up to the last slash represents a directory prefix. The scope of that pathspec is limited to that subtree.

•the rest of the pathspec is a pattern for the remainder of the pathname. Paths relative to the directory prefix will be matched against that pattern using fnmatch(3); in particular, * and ? can match directory separators.

For example, Documentation/*.jpg will match all .jpg files in the Documentation subtree, including Documentation/chapter_1/figure_1.jpg.

A pathspec that begins with a colon : has special meaning. In the short form, the leading colon : is followed by zero or more "magic signature" letters (which optionally is terminated by another colon :), and the remainder is the pattern to match against the path. The "magic signature" consists of ASCII symbols that are neither alphanumeric, glob, regex special characters nor colon. The optional colon that terminates the "magic signature" can be omitted if the pattern begins with a character that does not belong to "magic signature" symbol set and is not a colon.

In the long form, the leading colon : is followed by an open parenthesis (, a comma-separated list of zero or more "magic words", and a close parentheses ), and the remainder is the pattern to match against the path.

A pathspec with only a colon means "there is no pathspec". This form should not be combined with other pathspec.

top

The magic word top (magic signature: /) makes the pattern match from the root of the working tree, even when you are running the command from inside a subdirectory.

literal

Wildcards in the pattern such as * or ? are treated as literal characters.

icase

Case insensitive match.

glob

Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html". Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

•A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".

•A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.

•A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.

•Other consecutive asterisks are considered invalid. Glob magic is incompatible with literal magic.

attr

After attr: comes a space separated list of "attribute requirements", all of which must be met in order for the path to be considered a match; this is in addition to the usual non-magic pathspec pattern matching. See gitattributes(5). Each of the attribute requirements for the path takes one of these forms:

•"ATTR" requires that the attribute ATTR be set.

•"-ATTR" requires that the attribute ATTR be unset.

•"ATTR=VALUE" requires that the attribute ATTR be set to the string VALUE.

•"!ATTR" requires that the attribute ATTR be unspecified. Note that when matching against a tree object, attributes are still obtained from working tree, not from the given tree object.

exclude

After a path matches any non-exclude pathspec, it will be run through all exclude pathspecs (magic signature: ! or its synonym ^). If it matches, the path is ignored. When there is no non-exclude pathspec, the exclusion is applied to the result set as if invoked without any pathspec.

parent

A commit object contains a (possibly empty) list of the logical predecessor(s) in the line of development, i.e. its parents.

peel

The action of recursively dereferencing a tag object.

pickaxe

The term pickaxe refers to an option to the diffcore routines that help select changes that add or delete a given text string. With the --pickaxe-all option, it can be used to view the full changeset that introduced or removed, say, a particular line of text. See git-diff(1).

plumbing

Cute name for core Git.

porcelain

Cute name for programs and program suites depending on core Git, presenting a high level access to core Git. Porcelains expose more of a SCM interface than the plumbing.

per-worktree ref

Refs that are per-worktree, rather than global. This is presently only HEAD and any refs that start with refs/bisect/, but might later include other unusual refs.

pseudoref

A ref that has different semantics than normal refs. These refs can be read via normal Git commands, but cannot be written to by commands like git-update-ref(1). The following pseudorefs are known to Git:

•FETCH_HEAD is written by git-fetch(1) or git-pull(1). It may refer to multiple object IDs. Each object ID is annotated with metadata indicating where it was fetched from and its fetch status.

•MERGE_HEAD is written by git-merge(1) when resolving merge conflicts. It contains all commit IDs which are being merged.

pull

Pulling a branch means to fetch it and merge it. See also git-pull(1).

push

Pushing a branch means to get the branch’s head ref from a remote repository, find out if it is an ancestor to the branch’s local head ref, and in that case, putting all objects, which are reachable from the local head ref, and which are missing from the remote repository, into the remote object database, and updating the remote head ref. If the remote head is not an ancestor to the local head, the push fails.

reachable

All of the ancestors of a given commit are said to be "reachable" from that commit. More generally, one object is reachable from another if we can reach the one from the other by a chain that follows tags to whatever they tag, commits to their parents or trees, and trees to the trees or blobs that they contain.

reachability bitmaps

Reachability bitmaps store information about the reachability of a selected set of commits in a packfile, or a multi-pack index (MIDX), to speed up object search. The bitmaps are stored in a ".bitmap" file. A repository may have at most one bitmap file in use. The bitmap file may belong to either one pack, or the repository’s multi-pack index (if it exists).

rebase

To reapply a series of changes from a branch to a different base, and reset the head of that branch to the result.

ref

A name that points to an object name or another ref (the latter is called a symbolic ref). For convenience, a ref can sometimes be abbreviated when used as an argument to a Git command; see gitrevisions(7) for details. Refs are stored in the repository. The ref namespace is hierarchical. Ref names must either start with refs/ or be located in the root of the hierarchy. For the latter, their name must follow these rules:

•The name consists of only upper-case characters or underscores.

•The name ends with "_HEAD" or is equal to "HEAD". There are some irregular refs in the root of the hierarchy that do not match these rules. The following list is exhaustive and shall not be extended in the future:

•AUTO_MERGE

•BISECT_EXPECTED_REV

•NOTES_MERGE_PARTIAL

•NOTES_MERGE_REF

•MERGE_AUTOSTASH Different subhierarchies are used for different purposes. For example, the refs/heads/ hierarchy is used to represent local branches whereas the refs/tags/ hierarchy is used to represent local tags..

reflog

A reflog shows the local "history" of a ref. In other words, it can tell you what the 3rd last revision in this repository was, and what was the current state in this repository, yesterday 9:14pm. See git-reflog(1) for details.

refspec

A "refspec" is used by fetch and push to describe the mapping between remote ref and local ref. See git-fetch(1) or git-push(1) for details.

remote repository

A repository which is used to track the same project but resides somewhere else. To communicate with remotes, see fetch or push.

remote-tracking branch

A ref that is used to follow changes from another repository. It typically looks like refs/remotes/foo/bar (indicating that it tracks a branch named bar in a remote named foo), and matches the right-hand-side of a configured fetch refspec. A remote-tracking branch should not contain direct modifications or have local commits made to it.

repository

A collection of refs together with an object database containing all objects which are reachable from the refs, possibly accompanied by meta data from one or more porcelains. A repository can share an object database with other repositories via alternates mechanism.

resolve

The action of fixing up manually what a failed automatic merge left behind.

revision

Synonym for commit (the noun).

rewind

To throw away part of the development, i.e. to assign the head to an earlier revision.

SCM

Source code management (tool).

SHA-1

"Secure Hash Algorithm 1"; a cryptographic hash function. In the context of Git used as a synonym for object name.

shallow clone

Mostly a synonym to shallow repository but the phrase makes it more explicit that it was created by running git clone --depth=... command.

shallow repository

A shallow repository has an incomplete history some of whose commits have parents cauterized away (in other words, Git is told to pretend that these commits do not have the parents, even though they are recorded in the commit object). This is sometimes useful when you are interested only in the recent history of a project even though the real history recorded in the upstream is much larger. A shallow repository is created by giving the --depth option to git-clone(1), and its history can be later deepened with git-fetch(1).

stash entry

An object used to temporarily store the contents of a dirty working directory and the index for future reuse.

submodule

A repository that holds the history of a separate project inside another repository (the latter of which is called superproject).

superproject

A repository that references repositories of other projects in its working tree as submodules. The superproject knows about the names of (but does not hold copies of) commit objects of the contained submodules.

symref

Symbolic reference: instead of containing the SHA-1 id itself, it is of the format ref: refs/some/thing and when referenced, it recursively dereferences to this reference. HEAD is a prime example of a symref. Symbolic references are manipulated with the git-symbolic-ref(1) command.

tag

A ref under refs/tags/ namespace that points to an object of an arbitrary type (typically a tag points to either a tag or a commit object). In contrast to a head, a tag is not updated by the commit command. A Git tag has nothing to do with a Lisp tag (which would be called an object type in Git’s context). A tag is most typically used to mark a particular point in the commit ancestry chain.

tag object

An object containing a ref pointing to another object, which can contain a message just like a commit object. It can also contain a (PGP) signature, in which case it is called a "signed tag object".

topic branch

A regular Git branch that is used by a developer to identify a conceptual line of development. Since branches are very easy and inexpensive, it is often desirable to have several small branches that each contain very well defined concepts or small incremental yet related changes.

trailer

Key-value metadata. Trailers are optionally found at the end of a commit message. Might be called "footers" or "tags" in other communities. See git-interpret-trailers(1).

tree

Either a working tree, or a tree object together with the dependent blob and tree objects (i.e. a stored representation of a working tree).

tree object

An object containing a list of file names and modes along with refs to the associated blob and/or tree objects. A tree is equivalent to a directory.

tree-ish (also treeish)

A tree object or an object that can be recursively dereferenced to a tree object. Dereferencing a commit object yields the tree object corresponding to the revision's top directory. The following are all tree-ishes: a commit-ish, a tree object, a tag object that points to a tree object, a tag object that points to a tag object that points to a tree object, etc.

unborn

The HEAD can point at a branch that does not yet exist and that does not have any commit on it yet, and such a branch is called an unborn branch. The most typical way users encounter an unborn branch is by creating a repository anew without cloning from elsewhere. The HEAD would point at the main (or master, depending on your configuration) branch that is yet to be born. Also some operations can get you on an unborn branch with their orphan option.

unmerged index

An index which contains unmerged index entries.

unreachable object

An object which is not reachable from a branch, tag, or any other reference.

upstream branch

The default branch that is merged into the branch in question (or the branch in question is rebased onto). It is configured via branch.<name>.remote and branch.<name>.merge. If the upstream branch of A is origin/B sometimes we say "A is tracking origin/B".

working tree

The tree of actual checked out files. The working tree normally contains the contents of the HEAD commit’s tree, plus any local changes that you have made but not yet committed.

worktree

A repository can have zero (i.e. bare repository) or one or more worktrees attached to it. One "worktree" consists of a "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, per-worktree refs and per-worktree configuration file).

## SEE ALSO
gittutorial(7), gittutorial-2(7), gitcvs-migration(7), giteveryday(7), The Git User’s Manual[1]

## GIT
Part of the git(1) suite

## NOTES
1.

The Git User’s Manual

file:///usr/share/doc/git/user-manual.html


gitnamespaces

title: gitnamespaces(7)

summary: Git namespaces

text:
# gitnamespaces(7)

## NAME
gitnamespaces - Git namespaces

## SYNOPSIS

```
GIT_NAMESPACE=<namespace> git upload-pack
GIT_NAMESPACE=<namespace> git receive-pack
```

## DESCRIPTION
Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD. Git can expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to operations such as git-gc(1).

Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when storing multiple branches of the same source. The alternates mechanism provides similar support for avoiding duplicates, but alternates do not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do.

To specify a namespace, set the GIT_NAMESPACE environment variable to the namespace. For each ref namespace, Git stores the corresponding refs in a directory under refs/namespaces/. For example, GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/. You can also specify namespaces via the --namespace option to git(1).

Note that namespaces which include a / will expand to a hierarchy of namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under refs/namespaces/foo/refs/namespaces/bar/. This makes paths in GIT_NAMESPACE behave hierarchically, so that cloning with GIT_NAMESPACE=foo/bar produces the same result as cloning with GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar. It also avoids ambiguity with strange namespace paths such as foo/refs/heads/, which could otherwise generate directory/file conflicts within the refs directory.

git-upload-pack(1) and git-receive-pack(1) rewrite the names of refs as specified by GIT_NAMESPACE. git-upload-pack and git-receive-pack will ignore all references outside the specified namespace.

The smart HTTP server, git-http-backend(1), will pass GIT_NAMESPACE through to the backend programs; see git-http-backend(1) for sample configuration to expose repository namespaces as repositories.

For a simple local test, you can use git-remote-ext(1):

```
git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
```

## SECURITY
The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository.

The known attack vectors are as follows:

1.The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them. The attacker chooses an object ID X to steal and sends a ref to X, but isn’t required to send the content of X because the victim already has it. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge.)

2.As in #1, the attacker chooses an object ID X to steal. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X. The delta reveals regions of X that are similar to Y to the attacker.

## GIT
Part of the git(1) suite


gitpacking

title: gitpacking(7)

text:
# gitpacking(7)

## NAME
gitpacking - Advanced concepts related to packing in Git

## SYNOPSIS
gitpacking

## DESCRIPTION
This document aims to describe some advanced concepts related to packing in Git.

Many concepts are currently described scattered between manual pages of various Git commands, including git-pack-objects(1), git-repack(1), and others, as well as gitformat-pack(5), and parts of the Documentation/technical tree.

There are many aspects of packing in Git that are not covered in this document that instead live in the aforementioned areas. Over time, those scattered bits may coalesce into this document.

## PSEUDO-MERGE BITMAPS

Note Pseudo-merge bitmaps are considered an experimental feature, so the configuration and many of the ideas are subject to change.

### Background
Reachability bitmaps are most efficient when we have on-disk stored bitmaps for one or more of the starting points of a traversal. For this reason, Git prefers storing bitmaps for commits at the tips of refs, because traversals tend to start with those points.

But if you have a large number of refs, it’s not feasible to store a bitmap for every ref tip. It takes up space, and just OR-ing all of those bitmaps together is expensive.

One way we can deal with that is to create bitmaps that represent groups of refs. When a traversal asks about the entire group, then we can use this single bitmap instead of considering each ref individually. Because these bitmaps represent the set of objects which would be reachable in a hypothetical merge of all of the commits, we call them pseudo-merge bitmaps.

### Overview
A "pseudo-merge bitmap" is used to refer to a pair of bitmaps, as follows:

Commit bitmap

A bitmap whose set bits describe the set of commits included in the pseudo-merge’s "merge" bitmap (as below).

Merge bitmap

A bitmap whose set bits describe the reachability closure over the set of commits in the pseudo-merge’s "commits" bitmap (as above). An identical bitmap would be generated for an octopus merge with the same set of parents as described in the commits bitmap.

Pseudo-merge bitmaps can accelerate bitmap traversals when all commits for a given pseudo-merge are listed on either side of the traversal, either directly (by explicitly asking for them as part of the HAVES or WANTS) or indirectly (by encountering them during a fill-in traversal).

### Use-cases
For example, suppose there exists a pseudo-merge bitmap with a large number of commits, all of which are listed in the WANTS section of some bitmap traversal query. When pseudo-merge bitmaps are enabled, the bitmap machinery can quickly determine there is a pseudo-merge which satisfies some subset of the wanted objects on either side of the query. Then, we can inflate the EWAH-compressed bitmap, and OR it in to the resulting bitmap. By contrast, without pseudo-merge bitmaps, we would have to repeat the decompression and OR-ing step over a potentially large number of individual bitmaps, which can take proportionally more time.

Another benefit of pseudo-merges arises when there is some combination of (a) a large number of references, with (b) poor bitmap coverage, and (c) deep, nested trees, making fill-in traversal relatively expensive. For example, suppose that there are a large enough number of tags where bitmapping each of the tags individually is infeasible. Without pseudo-merge bitmaps, computing the result of, say, git rev-list --use-bitmap-index --count --objects --tags would likely require a large amount of fill-in traversal. But when a large quantity of those tags are stored together in a pseudo-merge bitmap, the bitmap machinery can take advantage of the fact that we only care about the union of objects reachable from all of those tags, and answer the query much faster.

### Configuration
Reference tips are grouped into different pseudo-merge groups according to two criteria. A reference name matches one or more of the defined pseudo-merge patterns, and optionally one or more capture groups within that pattern which further partition the group.

Within a group, commits may be considered "stable", or "unstable" depending on their age. These are adjusted by setting the bitmapPseudoMerge.<name>.stableThreshold and bitmapPseudoMerge.<name>.threshold configuration values, respectively.

All stable commits are grouped into pseudo-merges of equal size (bitmapPseudoMerge.<name>.stableSize). If the stableSize configuration is set to, say, 100, then the first 100 commits (ordered by committer date) which are older than the stableThreshold value will form one group, the next 100 commits will form another group, and so on.

Among unstable commits, the pseudo-merge machinery will attempt to combine older commits into large groups as opposed to newer commits which will appear in smaller groups. This is based on the heuristic that references whose tip commit is older are less likely to be modified to point at a different commit than a reference whose tip commit is newer.

The size of groups is determined by a power-law decay function, and the decay parameter roughly corresponds to "k" in f(n) = C*n^(-k/100), where f(n) describes the size of the n-th pseudo-merge group. The sample rate controls what percentage of eligible commits are considered as candidates. The threshold parameter indicates the minimum age (so as to avoid including too-recent commits in a pseudo-merge group, making it less likely to be valid). The "maxMerges" parameter sets an upper-bound on the number of pseudo-merge commits an individual group

The "stable"-related parameters control "stable" pseudo-merge groups, comprised of a fixed number of commits which are older than the configured "stable threshold" value and may be grouped together in chunks of "stableSize" in order of age.

The exact configuration for pseudo-merges is as follows:

Note The configuration options in bitmapPseudoMerge.* are considered EXPERIMENTAL and may be subject to change or be removed entirely in the future. For more information about the pseudo-merge bitmap feature, see the "Pseudo-merge bitmaps" section of gitpacking(7).

bitmapPseudoMerge.<name>.pattern

Regular expression used to match reference names. Commits pointed to by references matching this pattern (and meeting the below criteria, like bitmapPseudoMerge.<name>.sampleRate and bitmapPseudoMerge.<name>.threshold) will be considered for inclusion in a pseudo-merge bitmap. Commits are grouped into pseudo-merge groups based on whether or not any reference(s) that point at a given commit match the pattern, which is an extended regular expression.

Within a pseudo-merge group, commits may be further grouped into sub-groups based on the capture groups in the pattern. These sub-groupings are formed from the regular expressions by concatenating any capture groups from the regular expression, with a - dash in between.

For example, if the pattern is refs/tags/, then all tags (provided they meet the below criteria) will be considered candidates for the same pseudo-merge group. However, if the pattern is instead refs/remotes/([0-9])+/tags/, then tags from different remotes will be grouped into separate pseudo-merge groups, based on the remote number.

bitmapPseudoMerge.<name>.decay

Determines the rate at which consecutive pseudo-merge bitmap groups decrease in size. Must be non-negative. This parameter can be thought of as k in the function f(n) = C * n^-k, where f(n) is the size of the `n`th group. Setting the decay rate equal to 0 will cause all groups to be the same size. Setting the decay rate equal to 1 will cause the n`th group to be `1/n the size of the initial group. Higher values of the decay rate cause consecutive groups to shrink at an increasing rate. The default is 1.

If all groups are the same size, it is possible that groups containing newer commits will be able to be used less often than earlier groups, since it is more likely that the references pointing at newer commits will be updated more often than a reference pointing at an old commit.

bitmapPseudoMerge.<name>.sampleRate

Determines the proportion of non-bitmapped commits (among reference tips) which are selected for inclusion in an unstable pseudo-merge bitmap. Must be between 0 and 1 (inclusive). The default is 1.

bitmapPseudoMerge.<name>.threshold

Determines the minimum age of non-bitmapped commits (among reference tips, as above) which are candidates for inclusion in an unstable pseudo-merge bitmap. The default is 1.week.ago.

bitmapPseudoMerge.<name>.maxMerges

Determines the maximum number of pseudo-merge commits among which commits may be distributed. For pseudo-merge groups whose pattern does not contain any capture groups, this setting is applied for all commits matching the regular expression. For patterns that have one or more capture groups, this setting is applied for each distinct capture group.

For example, if your capture group is refs/tags/, then this setting will distribute all tags into a maximum of maxMerges pseudo-merge commits. However, if your capture group is, say, refs/remotes/([0-9]+)/tags/, then this setting will be applied to each remote’s set of tags individually.

Must be non-negative. The default value is 64.

bitmapPseudoMerge.<name>.stableThreshold

Determines the minimum age of commits (among reference tips, as above, however stable commits are still considered candidates even when they have been covered by a bitmap) which are candidates for a stable a pseudo-merge bitmap. The default is 1.month.ago. Setting this threshold to a smaller value (e.g., 1.week.ago) will cause more stable groups to be generated (which impose a one-time generation cost) but those groups will likely become stale over time. Using a larger value incurs the opposite penalty (fewer stable groups which are more useful).

bitmapPseudoMerge.<name>.stableSize

Determines the size (in number of commits) of a stable psuedo-merge bitmap. The default is 512.

### Examples
Suppose that you have a repository with a large number of references, and you want a bare-bones configuration of pseudo-merge bitmaps that will enhance bitmap coverage of the refs/ namespace. You may start with a configuration like so:

```
[bitmapPseudoMerge "all"]

        pattern = "refs/"

        threshold = now

        stableThreshold = never

        sampleRate = 100

        maxMerges = 64
```

This will create pseudo-merge bitmaps for all references, regardless of their age, and group them into 64 pseudo-merge commits.

If you wanted to separate tags from branches when generating pseudo-merge commits, you would instead define the pattern with a capture group, like so:

```
[bitmapPseudoMerge "all"]

        pattern = "refs/(heads/tags)/"
```

Suppose instead that you are working in a fork-network repository, with each fork specified by some numeric ID, and whose refs reside in refs/virtual/NNN/ (where NNN is the numeric ID corresponding to some fork) in the network. In this instance, you may instead write something like:

```
[bitmapPseudoMerge "all"]

        pattern = "refs/virtual/([0-9]+)/(heads|tags)/"

        threshold = now

        stableThreshold = never

        sampleRate = 100

        maxMerges = 64
```

Which would generate pseudo-merge group identifiers like "1234-heads", and "5678-tags" (for branches in fork "1234", and tags in remote "5678", respectively).

## SEE ALSO
git-pack-objects(1) git-repack(1)

## GIT
Part of the git(1) suite