0

Lets say I do a git checkout -b my_new_branch. Making some changes to my local files and after this I add all files with git add. and commit it and push. After this i realize that my branch is messed up and I want to delete it.

So Im going back to my master with git checkout master and delete the branch with git branch -D my_new_branch.

Will all local changes be reversed?

Garrett
  • 4,007
  • 2
  • 41
  • 59
Denny Mueller
  • 3,505
  • 5
  • 36
  • 67

1 Answers1

0

Once you checkout the master branch, all of the changes that you made on my_new_branch will no longer be in your working directory. They will still be on your branch and on the server.

Once you delete my_new_branch, the ref to that branch will be deleted. The commits will still exist in your local repository until a garbage collection is run. The commits and branch will also still exist on the remote server.

Jordan Lewis
  • 16,900
  • 4
  • 29
  • 46
  • Lets say i have a index.html and I change this file in a branch. Will there be 2 version of this file in my local working directory? Or will git upload the my_new_branch file and download the master index.html? – Denny Mueller Nov 09 '12 at 20:34
  • 1
    There will never be more than one version of a particular file in your working directory. When you checkout a new branch, git updates all of the files in your working directory to be the same as they are on that branch. Does that help? You might want to make a practice repo to try this stuff out on. Also, read the git book! http://git-scm.com/book – Jordan Lewis Nov 09 '12 at 21:07