LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can clean delete the "git branch"? (http://www.linuxquestions.org/questions/linux-software-2/how-can-clean-delete-the-git-branch-4175432413/)

poplinux 10-16-2012 02:02 AM

How can clean delete the "git branch"?
 
Dear Sir.

I'm want to use GIT. But git is not easy to me.

I'm work on new branch But, have a misstake, for example wrong file to add.

So. I'm want to delete branch and restart my work.

My proceduer, see below.

step 1. git clone git@test.net:test
step 2. git branch test
step 3. git checkout test
step 4. Add some file(add wrong file to my directory)
step 5. git checkout master(not commit)
step 6. git branch -D test
step 7. git branch new
step 8. git checkout new
step 9. git status

But wrong file was exist. Not delete.

How can clean remove my branch?

Thank you

Snark1994 10-16-2012 07:18 AM

Well, you haven't committed the file. 'git status' should list the file as untracked, and you should be able to delete the file normally (i.e. with 'rm') without using any git commands.

Hope this helps,

poplinux 10-16-2012 07:16 PM

Dear Snark.

Thank's your reply.

I'm already add and commit using "git add" and "git commit -a" (step 4).

Snark1994 10-17-2012 03:27 AM

Ah, I was confused by your saying "not commit" in step 5.

But if I recreate your steps:
Code:

$ git init
Initialized empty Git repository in /home/joshua/test/git/.git/
$ touch foo
git add foo
$ git commit
[master (root-commit) 81a8286] Initial commit
 0 files changed
 create mode 100644 foo
$ git branch test
$ git checkout test
Switched to branch 'test'
$ touch bah
$ git commit
[test e11766c] Added bad file bah
 0 files changed
 create mode 100644 bah
$ ls
foo  bah
$ git checkout master
Switched to branch 'master'
$ git branch -D test
Deleted branch test (was e11766c).
$ ls
foo
$

So I suspect you've run other commands as well. Perhaps the easiest to do would be to post the output of:

Code:

git log --grapch --oneline --all
and

Code:

git status
Regards,


All times are GMT -5. The time now is 06:52 PM.