Jump to content

Removing pulled git branch


Guest TheCastellum

Recommended Posts

Hello,

I haven't really used Git much, so forgive me for my ignorance. I was downloading some of the branches of different addon-projects and it failed to compile, and I would just prefer to remove it. I used the following method to acquire the source:

git pull git://github.com/Paradox/mangos.git master

Now, I know I can just start all over, but I have other custom code added, and it would be a pain to re-add it all. And if there is no way to do it with the method I used, is there a better method that would allow me management of the specific branches I download?

Thank you in advance,

TheCastellum.

Link to comment
Share on other sites

Since you asked so nicely;

As you may know, a pull is fetch+merge (ie. download objects + somewhat connect several branches). Merge connects two or more branches, so you can just hard-reset to previous state of any of them.

Imagine you have your own branch (left) and just merged another one (via pull):

|
*
|
M
|  \\
*  *
|   |
*  *
|   |

git-reset accepts several referency specification formats, HEAD~1 (or branchname~1) refers to "one commit back" (or "the second topmost commit of branchname"). Thus, when you're at point "M" (ie. your last commit is the merge), you can simply git reset --hard HEAD~1 to get your clean state before any merge. A special syntax can be used for merges, HEAD^ or HEAD^1 means the first parent, HEAD^2 the second, ..., see "man git-rev-parse" (section SPECIFYING REVISIONS) for a complete manual.

Another way is to use reflog, something like HEAD@{1} means "HEAD one step back". You can use HEAD@{10.minutes.ago} , which - surprisingly - works as well!

Link to comment
Share on other sites

Hello again,

I tried to remove another branch using the first method, but git gives me the following error:

Interactive rebase already started

After looking on Google, I discovered how to fix this, but sadly the fix does not seem to work on Windows platforms. The solution I found for Linux (and possibly Windows, but does not work on my machine) is as follows:

cd .git
rm -rf .dotest-merge

There is no such directory in my .git directory, so I am wondering if it something that only has to do with Linux git exclusively.

Any ideas are welcome,

TheCastellum.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use