“I wrote code in a different branch and I need it in gh-pages”

git-branch
merge
js211
git
#1

If you experienced this, no worries! Here’s how you get all the work you wrote into a branch of your choice.

First things first, what branch are you working in? Get the list of branches and the one you’re currently on with:

  • git branch

In the current branch (where you wrote your code), run through all the commands to push it up.

  • git add .
  • git commit -m “leave a message”
  • git push origin <insert-name-of-current-branch>

Then switch over to the branch you want to be in (gh-pages)

  • git checkout gh-pages

Run through all the commands again to push any changes you might have made in gh-pages. You might not have any! But doesn’t hurt to be sure.

  • git add .
  • git commit -m “leave a message”
  • git push origin <insert-name-of-current-branch>

Then you’ll merge the two branches.

  • git merge <name-of-branch-you-want-merged-with-gh-pages>

You should get a list of all new files in red. If not,

  • git status

Push up new stuff and you’re good to go!

If there are errors or issues during this process, read the terminal messages. (merge conflicts are pretty common so no stress!) Git’s pretty good at giving you advice on what to do. Ask google before doing anything and/or ask me or a tutor!

Isn’t coding sooooooo fun!?!