Git-2.46.1

Introduction to Git

Git is a free and open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do. Git is used for version control of files, much like tools such as Mercurial, Bazaar, Subversion, CVS, Perforce, and Team Foundation Server.

[Note]

Note

Development versions of GLFS may not build or run some packages properly if LFS or dependencies have been updated since the most recent stable versions of the books.

Additional Downloads

Git Dependencies

Recommended

Installation of Git

Install Git by running the following commands:

./configure --prefix=/usr \
            --with-gitconfig=/etc/gitconfig \
            --with-python=python3 &&
make

The test suite can be run in parallel mode. To run the test suite, issue: make test -k |& tee test.log. If some test fails, the list of failed tests can be shown via grep '^not ok' test.log | grep -v TODO.

Now, as the root user:

make perllibdir=/usr/lib/perl5/5.38/site_perl install

If you downloaded the man pages and/or html docs

If you downloaded the man pages untar them as the root user:

tar -xf ../git-manpages-2.46.1.tar.xz \
    -C /usr/share/man --no-same-owner --no-overwrite-dir

If you downloaded the html docs untar them as the root user:

mkdir -vp   /usr/share/doc/git-2.46.1 &&
tar   -xf   ../git-htmldocs-2.46.1.tar.xz \
      -C    /usr/share/doc/git-2.46.1 --no-same-owner --no-overwrite-dir &&

find        /usr/share/doc/git-2.46.1 -type d -exec chmod 755 {} \; &&
find        /usr/share/doc/git-2.46.1 -type f -exec chmod 644 {} \;

Reorganize text and html in the html-docs

The html-docs include a lot of plain text files. Reorganize the files as the root user:

mkdir -vp /usr/share/doc/git-2.46.1/man-pages/{html,text}         &&
mv        /usr/share/doc/git-2.46.1/{git*.txt,man-pages/text}     &&
mv        /usr/share/doc/git-2.46.1/{git*.,index.,man-pages/}html &&

mkdir -vp /usr/share/doc/git-2.46.1/technical/{html,text}         &&
mv        /usr/share/doc/git-2.46.1/technical/{*.txt,text}        &&
mv        /usr/share/doc/git-2.46.1/technical/{*.,}html           &&

mkdir -vp /usr/share/doc/git-2.46.1/howto/{html,text}             &&
mv        /usr/share/doc/git-2.46.1/howto/{*.txt,text}            &&
mv        /usr/share/doc/git-2.46.1/howto/{*.,}html               &&

sed -i '/^<a href=/s|howto/|&html/|' /usr/share/doc/git-2.46.1/howto-index.html &&
sed -i '/^\* link:/s|howto/|&html/|' /usr/share/doc/git-2.46.1/howto-index.txt

Using Git

This Git installation doesn't have the full power Git can provide, such as scheduling and the like. If you want even more features, check https://linuxfromscratch.org/blfs/view/svn/general/git.html. However, this installation if you installed cURL-8.9.1 can provide enough features to be of good use for you, such as the ability to clone repos. This is sometimes a necessity when developers don't publish releases or haven't in a long time, so the repo is the only way to obtain the (hopefully) up to date package. In order to clone a repo, simply invoke:

git clone https://path/to/repo.git

The above command will then clone the entire repository besides subprojects, something that some projects do and require special instructions. A directory will be created, called repo, in the current working directory, with all the repo's files being in that just created directory. If you want to for some reason change the directory name, you can do it when you clone the repo, like so:

git clone https://path/to/repo.git newname

The above command will create the directory called newname and put all the repo's files in that directory. Eventually you'll come across a repository that has some subprojects, for instance an emulator that depends on graphic libraries and intends to compile a static version of it. In order to pull in those subprojects, you must also invoke the --recurse-submodules option. This will clone all the subprojects and check them out.

Git Repo vs Release Archives

All of the packages in GLFS, except for when obtaing firmware, have you download tarballs or zipfiles. These tarballs and zipfiles were created as part of a release, and often include files not found in the repo equivalent where the package development happens. Usually the extra included files are the configure scripts you should now be used to using. They are generated manually using aclocal, autoconf , and automake. The configure scripts are often not in the repos, so if the git repo gets cloned, you will have to generate the configure script yourself if you find configure.ac, Makefile.am, and possibly autogen.sh . You won't need to do this if you find the repo has a Makefile or has meson_options.txt or CMakeLists.txt.

Another big difference between the repo and the release package is that the repo probably has had commits after the last release if it had any, and new commits can introduce bugs or prevent compilation. When developers prepare a new release, often they search for issues, bugs, and compilation errors, making it stable before they publish the release and its related package files. Release packages aren't entirely safe from issues and can help with causing issues as files can be added. Sometimes you can tell if something is wrong, sometimes you can't. It's always important to be up to date with security news to prevent damage.

Command Explanations

--with-gitconfig=/etc/gitconfig: This sets /etc/gitconfig as the file that stores the default, system wide, Git settings.

--with-python=python3: Use this switch to use Python 3, instead of the EOL'ed Python 2. Python is used for the git p4 interface to Perforce repositories, and also used in some tests.

--with-libpcre2: Use this switch if PCRE2 is installed.

tar -xf ../git-manpages-2.46.1.tar.gz -C /usr/share/man --no-same-owner: This untars git-manpages-2.46.1.tar.gz. The -C option makes tar change directory to /usr/share/man before it starts to decompress the docs. The --no-same-owner option stops tar from preserving the user and group details of the files. This is useful as that user or group may not exist on your system; this could (potentially) be a security risk.

mv /usr/share/doc/git-2.46.1 ...: These commands move some of the files into subfolders to make it easier to sort through the docs and find what you're looking for.

find ... chmod ...: These commands correct the permissions in the shipped documentation tar file.

Configuring Git

Config Files

~/.gitconfig and /etc/gitconfig

Contents

Installed Programs: git, git-receive-pack, git-upload-archive, and git-upload-pack (hardlinked to each other), git-cvsserver, git-shell, gitk, and scalar
Installed Libraries: None
Installed Directories: /usr/libexec/git-core, /usr/lib/perl5/5.38/site_perl/Git, and /usr/share/{doc/git-2.46.1,git-core,git-gui,gitk,gitweb}

Short Descriptions

git

is the stupid content tracker

git-cvsserver

is a CVS server emulator for Git

gitk

is a graphical Git repository browser (needs Tk)

git-receive-pack

is invoked by git send-pack and updates the repository with the information fed from the remote end

git-shell

is a login shell for SSH accounts to provide restricted Git access

git-upload-archive

is invoked by git archive --remote and sends a generated archive to the other end over the git protocol

git-upload-pack

is invoked by git fetch-pack, it discovers what objects the other side is missing, and sends them after packing

scalar

is a repository management tool that optimizes Git for use in large repositories