Tag: branch

How to get the current branch name in Git?

I’m from a Subversion background and, when I had a branch, I knew what I was working on with “These working files point to this branch”. But with Git I’m not sure when I am editing a file in NetBeans or Notepad++, whether it’s tied to the master or another branch. There’s no problem with […]

How can I search Git branches for a file or directory?

In Git, how could I search for a file or directory by path across a number of branches? I’ve written something in a branch, but I don’t remember which one. Now I need to find it. Clarification: I’m looking for a file which I created on one of my branches. I’d like to find it […]

Set up git to pull and push all branches

I’d like to push and pull all the branches by default, including the newly created ones. Is there a setting that I can define for it? Otherwise, when I add a new branch, locally and I want to pull it from the server, what is the simplest way to do it? I created a new […]

Forking vs. Branching in GitHub

I’d like to know more about the advantages and disadvantages of forking a github project vs. creating a branch of a github project. Forking makes my version of the project more isolated from the original one because I don’t have to be on the collaborators list of the original project. Since we’re developing a project […]

Branch from a previous commit using git

If I have n commits, how can I branch from the n-3 commit? I can see the hash of every commit.

How to get the changes on a branch in Git

What is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is: git log $(git merge-base HEAD branch)..branch The documentation for git-diff indicates that git diff A…B is equivalent to git diff $(git-merge-base A B) B. On the […]

Default behavior of “git push” without a branch specified

I use the following command to push to my remote branch: git push origin sandbox If I say git push origin does that push changes in my other branches too, or does it only update my current branch? I have three branches: master, production and sandbox. The git push documentation is not very clear about […]

How to clone a single branch in git?

I have a local git repository called ‘skeleton’ that I use for storing project skeletons. It has a few branches, for different kinds of projects: casey@agave [~/Projects/skeleton] git branch * master rails c c++ If I want to check out the master branch for a new project, I can do casey@agave [~/Projects] git clone skeleton […]

git branch, fork, fetch, merge, rebase and clone, what are the differences?

Can someone help me understand the difference between a branch, a fork and a clone in Git? Similarly, what does it mean when I do a git fetch as opposed to a git pull? Also, what does rebase mean in comparison to merge? How can I squash individual commits themselves together? How are they used, […]

How do you create a remote Git branch?

I created a local branch which I want to ‘push’ upstream. There is a similar question here on Stack Overflow on how to track a newly created remote branch. However, my workflow is slightly different. First I want to create a local branch, and I will only push it upstream when I’m satisfied and want […]

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