2

I need to create an orphan branch, which has no parent. How do I do it in Smartgit?

Need some guidance on this..

lakshmen
  • 28,346
  • 66
  • 178
  • 276

1 Answers1

2

That is one instance where, if SmartGit doesn't support the orphan option from the GUI, you could as well use the CLI (command-line interface) and type a quick:

git checkout --orphan newbranch

(as in "In git, is there a simple way of introducing an unrelated branch to a repository?")

Commit at least one file (still through the GUI):

git add afile
git commit -m "a first commit in orphan branch"
# no push here, this is purely a local operation in your local repo

Then you go back in SmartGit and your new (orphan) branch should be there.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • i did what you said-> but cannot see the branch in SmartGit – lakshmen Apr 03 '13 at 06:51
  • @lakesh I suspect because you need to make at least one commit in that new orphan branch. – VonC Apr 03 '13 at 06:52
  • this commit is thru CLI or Smartgit? – lakshmen Apr 03 '13 at 06:58
  • @lakesh through CLI (`git add afile`, `git commit -m "first commit"`), since that branch is not yet visible through SmartGit. – VonC Apr 03 '13 at 06:59
  • committing just pushes it to staging, doesn't push it to origin right? this is because, I am worried that it might affect the files in the repository. – lakshmen Apr 03 '13 at 07:15
  • @lakesh a commit doesn't push anything. If you are on your new branch, you will just create a commit on that new branch (in your local repo). No push is involved. – VonC Apr 03 '13 at 07:16
  • now can see the branch...Now i can add the new version of the code and commit and push normally.. am i right? – lakshmen Apr 03 '13 at 07:18
  • @lakesh great, I have added the first commit in the answer for more visibility. – VonC Apr 03 '13 at 07:19
  • you are correct...Now i can add the new version of the code and commit and push normally.. am i right? – lakshmen Apr 03 '13 at 07:20
  • @lakesh yes, once the branch is visible in SmartGit, it is back to business as usual. – VonC Apr 03 '13 at 07:22