0

I am not that used to working with these branches. But I thought I can make a branch from master and work on it and go back to master and wouldn't have the changes made to the child branch in the master (unless I merge them). But right now I "checked out" and am again in the master but see all child changes. Is this correct? Or what did I wrong? Check out means just changing to another branch and only merging would actually merge everything?

Cœur
  • 37,241
  • 25
  • 195
  • 267
MichiZH
  • 5,587
  • 12
  • 41
  • 81
  • What you describe is mostly correct so I guess you've done (maybe unadvertantly) something else you don't mention. Can you share what commands you typed ? A possible mistake would have been to create the child branch with a simple `git branch ` without doing an explicit checkout afterwards and assuming you now work on it (although *master* is still the current branch). It could explain what you describe. – Romain Valeri Oct 08 '18 at 13:36
  • Ok but in general if I checkout I am in a new branch and all changes won't be displayed int he other? And I won't lose any changes in either if I make now a merge to clean this mess up? I actually didn't type git commands I use source control in xcode, so maybe I didn't activate the child I don't know... – MichiZH Oct 08 '18 at 13:44
  • Yes, if you checkout a branch, git updates your working tree (your actual files on disk) to reflect its state, and changes in another branch will NOT show up. The thing is, your changes *could* have been on master all along if you happened to miss/forget the new branch checkout before modifying your files. – Romain Valeri Oct 08 '18 at 13:50
  • Have you committed changes in the child branch before checking out master? If not, [what you see is normal behaviour](https://stackoverflow.com/q/246275/7976758). – phd Oct 08 '18 at 14:40

0 Answers0