Tag: git branch

How to I “move” my commits from “no branch” to an actual branch?

I made a mistake, and started making commits “to the last tag”, which lands my commits in “no branch“. They should have been applied at the head of an already existing branch. I have not pushed my changes yet. I’ve found a few other question for when commits are in the wrong branch, but now […]

What is the difference between git push.default=current and push.default=upstream?

The man page for git-config lists these options for push.default: nothing – do not push anything. matching – push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default. upstream – push the current branch to its upstream branch. tracking – deprecated synonym for […]

How to determine when a Git branch was created?

Is there a way to determine when a Git branch was created? I have a branch in my repo and and I don’t remember creating it and thought maybe seeing the creation timestamp would jog my memory.

What are the differences between local branch, local tracking branch, remote branch and remote tracking branch?

I just started using Git and I got really confused between different branches. Can anyone help me to figure out what the following branch types are? local branches local tracking branches remote branches remote tracking branches What is the difference between them? And how do they work with each other? A quick demo code will […]

Git fetch remote branch

My colleague and I are working on the same repository we’ve branched it into two branches each technically for different projects, but they have similarities so we’ll sometimes want to commit back to the *master from the branch. However, I have the branch, how can my colleague pull that branch specifically. A git clone of […]

Where does a Git branch start and what is its length?

Every now and then I’m asked, on what commit a certain branch on git starts or if a certain commit has been created on a specific branch. The end point of a branch is pretty clear: that’s where the branch label sits. But – where did it start? The trivial answer would be: on that […]

How to create a new empty branch for a new project

We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start storing our files, and I would want other users […]

Move branch pointer to different commit without checkout

To move the branch pointer of a checked out branch, one can use the git reset –hard command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like tracked remote branch)?

Remove local branches no longer on remote

Is there a simple way to delete all local branches which do not have a remote equivalent? Example: Branches (local and remote) master origin/master origin/bug-fix-a origin/bug-fix-b origin/bug-fix-c Locally, I only have a master branch. Now I need to work on bug-fix-a, so I check it out, work on it, and push changes to the remote. […]

Is there a way to lock a branch in GIT

I have an idea of locking a repository from users pushing files into it by having a lock script in the GIT update hook since the push can only recognize the userid as arguments and not the branches. So i can lock the entire repo which is just locking a directory. Is there a way […]

Git Baby is a git and github fan, let's start git clone.