Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

created a sandbox project and created a 6.x-1.x. http://drupalcode.org/sandbox/serjas/1713192.git now ported module to 7, but dont know how to create a branch followed instruction here http://drupal.org/node/1066342

cd ajax_links_api (this is where 6.x-1.x module)
git checkout -b 7.x-1.x
git push origin 7.x-1.x

now a branch is created in drupal rep with same contents as 6.x-1.x! i supposed to get a blank tree! what went wrong?

share|improve this question
add comment (requires an account with 50 reputation)

2 Answers

up vote 2 down vote accepted

I would recommend checking out some git tutorials, as this question arises from a fundamental misunderstanding of git's behavior. Take this command:

git checkout -b 7.x-1.x

This command takes your existing git repository (i.e. the 6.x-1.x codebase on whatever branch you happened to have checked out), and creates a new branch based on it. Branches in git are little more than pointers to particular commits in history. All you did by issuing that command is create a 7.x-1.x pointer to your most recent commit. You could verify the pointer by checking the git repository:

cd ajax_links_api
cat .git/refs/heads/7.x-1.x

That command will return a SHA1 hash. That's the commit id to which the 7.x-1.x branch points.

If you want a blank working directory, i.e. no files at all, create a new, empty repository. If instead you're simply trying to author a new version of your software based on 6.x-1.x, then you've done exactly what you should. Make any upgrades to those files you want on the 7.x-1.x branch. When you're ready to merge it back to master, you can.

These are core concepts in most any version control system, but especially DVCS (Distributed Version Control Systems). I strongly urge reading some of those linked tutorials.

share|improve this answer
3  
I highly recommend the Pro Git PDF book at the top of those tutorials, it taught me everything I know about git – Clive Aug 9 '12 at 12:50
@Clive +1. ProGit is spectacular. – Christopher Aug 9 '12 at 12:51
@Christopher thanks :), also got instruction from drupal.org "Create your new branch while beeing in 6.x-1.x, make your changes that are required for your port, commit and push the branch.this way anyone can see what and how it was ported and it's easier to detect error that came due to the port." – Serjas Aug 10 '12 at 4:47
add comment (requires an account with 50 reputation)

I think there might be some confusion as to what the term 'branch' implies here...

If you create a branch, you're creating it from an existing tree (i.e. you're forking the code to be changed in one way or another). I don't think it would make sense for your new branch to be empty; also there's nothing on the docs page you linked to that suggests you should be expecting to receive an empty tree, so I'm pretty sure this is just a misunderstanding.

If you desperately need to create a blank (orphaned) branch, I believe you can do so like this:

git checkout --orphan NEWBRANCH

Disclaimer: I'm relatively new to git so if someone wants to tell me this is nonsense please do!

share|improve this answer
1  
Your command is right on, but in practice there are very few occasions --orphan would be the correct choice for any workflow. Not nonsense at all, though. – Christopher Aug 9 '12 at 12:42
@Christopher Thanks for the sanity check, I thought that was the case – Clive Aug 9 '12 at 12:49
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.