Keep the source from branch and content to master (Octopress)
I’ve tried octopress on github. I realize that it only shows the static html files in my [GitHub repo] (https://github.com/jslim89/jslim89.github.com). A question come out from my mind, that is What if I lost my source files (i.e. Rakefile, _config.yml, etc)?
A solution that I found is
1 2 3 4 5 6 7 8 9
$ git clone https://github.com/jslim89/jslim89.github.com.git $ cd jslim89.github.com # You should see those static HTML files $ git checkout source# It keeps all source in `source` branch, now no more HTML files $ mkdir _deploy $ cd _deploy $ git init $ git remote add origin https://github.com/jslim89/jslim89.github.com.git $ git pull origin master # check out the master (Static HTML files) $ cd ..
Actually during the octopress setup, they push the source to another branch rather than master.
When I type the same command to my learning journey, it has HEAD branch
1 2 3 4 5 6 7 8 9 10 11
$ git remote show origin * remote origin Fetch URL: git@github.com:jslim89/js-learning-journey.git Push URL: git@github.com:jslim89/js-learning-journey.git HEAD branch: master Remote branch: master tracked Local branch configured for'git pull': master merges with remote master Local ref configured for'git push': master pushes to master (up to date)
When first I see this, I was thinking about how to add master to the HEAD. In fact, it is not necessary
1 2 3 4 5 6 7 8
$ git push origin master Counting objects: 18, done. Delta compression using up to 4 threads. Compressing objects: 100% (16/16), done. Writing objects: 100% (18/18), 13.30 KiB, done. Total 18 (delta 1), reused 0 (delta 0) To git@yourdomain.com:/yourporject.git * [new branch] master -> master
Show origin again
1 2 3 4 5 6 7 8 9
$ git remote show origin * remote origin Fetch URL: git@yourdomain.com:/yourporject.git Push URL: git@yourdomain.com:/yourporject.git HEAD branch: master Remote branch: master tracked Local ref configured for'git push': master pushes to master (up to date)
Checkout specific revision
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Just to play safe, clone to a new folder $ git clone git@yourdomain.com:/yourporject.git $ git checkout <SHA1> Checking out files: 100% (6466/6466), done. Note: checking out '49869aec20e12345c40cbabcde0f5e8e959d5aa'.
You are in'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 49869ae... Your commit message here
$ git commit -am "completed version 1.0" # tag current commit on local $ git tag v1.0 $ git push origin master # push the tag to remote $ git push --tags # or git push origin v1.0