-- Drupal and Web Development

Notice: this post was last updated 3 years 28 weeks ago so it might be outdated. Please be cautious before implementing any of suggestions herein.

Git: Moving a to new branch, tracking a remote branch

Let's say you only have one local branch, master, which, and you want to create a new local branch, stage, to track the stage branch which exists remotely on the origin, you'll want to be careful how to create your new branch. This way is correct:

git checkout -b stage origin/stage

Whereas the following is incorrect, because you will wind up a stage branch integrating with whatever changes you have committed to master:

git checkout -b stage
git pull origin stage

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.