HOME

website as branch


ISSUE: now I have a repo website-gitbro/, I want to port it into my project Gitbro's main repo as a branch named website

Creat a empty branch--the podcast way

I went to gitcasts.com to see the podcast named git-empty-branch again.

the command that Scott used was:

git-symbolic-ref HEAD refs/heads/website

but my test looks like this(on my ubuntu 10.04 ):

Releas-:ptop:~/gitbro$ git-symbolic-ref HEAD refs/heads/website
git-symbolic-ref: command not found

this worked, but did not turn out to be expected:

peter@peter-laptop:~/gitbro$ git symbolic-ref HEAD refs/heads/website
peter@peter-laptop:~/gitbro$ git branch
  master

Note: the above git branch output is strange, there is no "*" preceeding the branch I think that's why I get this error:

peter@peter-laptop:~/gitbro$ git checkout -b website
fatal: You are on a branch yet to be born
peter@peter-laptop:~/gitbro$ ls .git/refs/heads/
master

all the following works correctly:

peter@peter-laptop:~/gitbro$ git rm --cached -r .
peter@peter-laptop:~/gitbro$ rm -rf * ## rm .gitignore manually here if you have one
peter@peter-laptop:~/gitbro$ git commit --allow-empty -m "init commit empty branch"

So, I am done with the branch Creation.

merge website-gitbro in

first I did was:

peter@peter-laptop:~/gitbro$ git checkout website 
Switched to branch 'website'
peter@peter-laptop:~/gitbro$ git remote add web ../website-gitbro/
peter@peter-laptop:~/gitbro$ git pull web master

things are done, but not nicely, since we now had a merge commit, obviously we need a rebase. but it seems I can not do a rebase since the two branch has no common Ancestor, can you?

push to the remote

peter@peter-laptop:~/gitbro$ git push origin website 
To git@github.com:happypeter/gitbro.git
 ! [rejected]        website -> website (non-fast-forward)

the story was that I did this several month ago, so that means I created a remote website branch, later I found I did not like it, So I deleted it. Now I see, it is obvious that I only did it locally, this is proved by doing this:

git clone git@github.com:happypeter/gitbro.git --branch website

and I successfully clone the gitbro, and it has only one branch:

peter@peter-laptop:~/xxx/ttt/gitbro$ git branch
* website
peter@peter-laptop:~/xxx/ttt/gitbro$

but I hated all the old stuff, how can I delete it on remote site?

Now the only way I know is to delete the whole git repo on the server, and push the local repo(without the branch website) to the server

this is simplely done by git push =git push= =origin website=

how to clone the whole repo from server (both branches included)

checked git-clone manpage, but got no direct answer, and what I did was:

  1. clone each branch separately

    git clone git@github.com:happypeter/gitbro.git ## this will clone only the master
    git clone git@github.com:happypeter/gitbro.git -b website website
    
  2. then do a push:

    cd website/
    git remote add ma ../gitbro
    git push  ma ## suprising is that you do not need to specify the branch name
    
  3. done

blog comments powered by Disqus