Tag: branch

List and delete git branches without cloning

for k in $(git branch -r –merged origin/master | cut -d” ” -f 3); do echo $k done I have a list of git projects that i want to clean up old branches in, what i want to do is list and delete all the branches that are merged to master. Is there a way […]

Let user push only to his own branch

Does anyone know how one can restrict push to some git repository branch based on “pusher’s” public key? Example: Alice wants to push changes to branch named “Bob” but push is refused on the server because her private key does not correspond to the public key stored in branch “Bob”. Only Bob has the corresponding […]

How do I move the past n commits to main, into a separate branch, with git?

say that i’ve been working in master, and i’ve just realized that maybe my last few commits (say, 15 of them) probably belong on a branch. how do i create a branch, containing all of the commits from a given past commit to the current head in master?

Git: Copy source code to new branch without history

I have 2 branches in git repository: common and myown. I want to copy the source from one branch to another branch but I want to see in history of common branch only commits related to feature migration (from myown to common). Is it possible to copy the source without the history or is a […]

Can I pull to a branch other than the one I'm on?

I need to be able to pull to a branch that I might not be on (in fact, assume for the sake of argument I don’t know what branch I’m on). For example, I have a remote origin with a branch master that is tracked locally in the usual way by a local master using […]

Isn't it strange to have branches for totally unrelated code with master?

Github does this for .io pages. A friend of mine worked at a company that had only one repo and 3 branches for backend, ios and android applications. This seems very strange since the definition of a branch is a state of code that’s derived from other state of the code in time. But those […]

How do I delete a local git branch when it can't look up commit object in 'refs/heads'?

Lately every git pull I do gives me an error message like: error: refs/heads/TestBranch123 does not point to a valid object! These are old branches and I don’t care, so I’d just like to delete them so I don’t see the error anymore. When I try to delete the branch I can’t for a similar […]

Identifying a tag belongs to which branch in git

I first did repo sync to a manifest for a branch name myBranch. I then get the tags from git tag -l Now I want to know using git that each tag obtained as a result of git tag -l was actually created on which branch. Please note : I do not want myBranch as […]

delete a file on my local branch using git

I have some changes in some of my files which were already there. Then I have added a new file in it using git add newfilename I didn’t commited yet, Now I want to delete this new file. I can’t do the reset as it will reset all other file changes also which I don;t […]

Is there a simple solution for importing different branches of software into a new git repository?

A little background. We have a bunch of homebrew software in the lab where I work. Many of the projects stem from the same source, but has no version history. At some point several of them were forked for different experimental purposes. We are in the process of putting all that software into git repositories. […]

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