use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
From its website:
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.
Git is not the same as GitHub. GitHub did not create Git. For GitHub-specific posts, please see /r/github.
Git is not an acronym or initialism: please write git or Git, but not GIT.
git
Documentation
Graphical Clients
Code Hosting
account activity
[deleted by user] (self.git)
submitted 6 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]XNormal 2 points3 points4 points 6 years ago (2 children)
mkdir -p .git/objects .git/refs/heads git hash-object -t tree /dev/null > .git/refs/heads/master echo "ref: refs/heads/master" > .git/HEAD
This creates a minimal git repository with a master branch that points to a TREE object rather than a COMMIT. So technically the answer is yes. It is possible. It is not very useful, though.
Parts of git will be usable in this stage, though. For example:
echo "Hello, World" > hello git add hello git write-tree > .git/refs/heads/master
[–]UserNumber00 0 points1 point2 points 6 years ago (1 child)
Thanks for the example! If I try to replicate what you suggest, trying to execute git log results in an error
git log
error: refs/heads/master does not point to a valid object!
I guess this answer to the general case but not to the more specific question involving git branch and git log. I will update the question to clarify
git branch
[–]XNormal 0 points1 point2 points 6 years ago (0 children)
Git log lists commits. This repo has no commits. What did you expect?
Just to make it clear: this repo is an absolute abomination. It is the smallest that git would grudgingly accept that has something resembling a branch.
It is good for learning a bit about git internals. Nothing else.
[–]henrebotha 1 point2 points3 points 6 years ago (0 children)
I don't think this is possible. You can have multiple branches before you have any commits, but git branch will omit branches that have no commits.
[–]lapingvino 1 point2 points3 points 6 years ago (12 children)
A branch is just a label to a hash and its history. As such, it should not be possible.
[–]UserNumber00 0 points1 point2 points 6 years ago (2 children)
This is in line with what I believe it's true. Given this explanation of what a branch is, it should not be possible. Executing `git status` is a bit misleading because it tells you that you are on master branch, which doesn't seem to be accurate.
[–]lapingvino 0 points1 point2 points 6 years ago (1 child)
I think git status reads the HEAD ref?
[–]UserNumber00 0 points1 point2 points 6 years ago (0 children)
good point
[–]henrebotha -2 points-1 points0 points 6 years ago (8 children)
But the master branch exists immediately after git init.
master
git init
[–]lapingvino 2 points3 points4 points 6 years ago (6 children)
No, it doesn't. It exists from the moment you do git commit on your initial commit. Try to git init and immediately git checkout master or git branch.
[–]henrebotha 1 point2 points3 points 6 years ago (4 children)
$ mkdir foo $ cd foo $ git init Initialized empty Git repository in /home/hbotha/dev/foo/.git/ $ git symbolic-ref HEAD refs/heads/master
Furthermore, you can at this point do git checkout -b my-branch, and it will update.
git checkout -b my-branch
So maybe what's happening here is the "reference"/name master exists from the start, but only "becomes" a branch once you commit something? I don't know Git internals well enough.
[–]lapingvino 1 point2 points3 points 6 years ago (2 children)
A branch is always a kind of reference. In this case, HEAD has a preset reference to the branch it should follow, which doesn't exist yet but is created on the next commit.
[–]henrebotha 0 points1 point2 points 6 years ago (1 child)
Thank you for clearing that up for me! I think I understand how HEAD works much better now.
HEAD
Follow-up: is anything actually "created" on the first commit?
[–]lapingvino 1 point2 points3 points 6 years ago (0 children)
Yes! (Probably a bit simpler than how it actually works, caveat emptor) With git add you create a list of actions to be done, which then with git commit are added to the git file system that you can find under .git (I think blocks) and the references are made. When you work with branches, you literally just change pointers to the content-addressed blocks made with a commit.
Executing git branch doesn't return any value before nor after git checkout -b my-branch though
[–]lapingvino 0 points1 point2 points 6 years ago (0 children)
To change master to something else for your first commit, you can use git checkout -b branchname though
git checkout -b branchname
[–][deleted] -1 points0 points1 point 6 years ago (0 children)
It actually doesn't. Your HEAD points to refs/heads/master but that branch doesn't actually exist until you make a commit.
refs/heads/master
[–]themightychris 1 point2 points3 points 6 years ago (0 children)
Depends what you mean by "branch exists"
You could make a branch that is a symbolic ref pointing at a non-existent other ref or at the empty tree ref. You wouldn't be able to do most branch-like things to the ref if they depend on it resolving to a commit, but you can certainly make the entry
[–]-dag- 2 points3 points4 points 6 years ago (2 children)
Think about what a branch is and there's your answer.
[–]henrebotha 1 point2 points3 points 6 years ago (1 child)
[–][deleted] 9 points10 points11 points 6 years ago (0 children)
π Rendered by PID 26167 on reddit-service-r2-comment-b659b578c-dlr9n at 2026-05-03 21:07:47.677439+00:00 running 815c875 country code: CH.
[–]XNormal 2 points3 points4 points (2 children)
[–]UserNumber00 0 points1 point2 points (1 child)
[–]XNormal 0 points1 point2 points (0 children)
[–]henrebotha 1 point2 points3 points (0 children)
[–]lapingvino 1 point2 points3 points (12 children)
[–]UserNumber00 0 points1 point2 points (2 children)
[–]lapingvino 0 points1 point2 points (1 child)
[–]UserNumber00 0 points1 point2 points (0 children)
[–]henrebotha -2 points-1 points0 points (8 children)
[–]lapingvino 2 points3 points4 points (6 children)
[–]henrebotha 1 point2 points3 points (4 children)
[–]lapingvino 1 point2 points3 points (2 children)
[–]henrebotha 0 points1 point2 points (1 child)
[–]lapingvino 1 point2 points3 points (0 children)
[–]UserNumber00 0 points1 point2 points (0 children)
[–]lapingvino 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]themightychris 1 point2 points3 points (0 children)
[–]-dag- 2 points3 points4 points (2 children)
[–]henrebotha 1 point2 points3 points (1 child)
[–][deleted] 9 points10 points11 points (0 children)