Git remote repository 생성 방법

Git를 사용하면서 원격 저장소를 셋업하려니 잘 안되네… 어제 그제 하루종일  삽질하다가 결국 구글신의 도움을 받아 해결했다. 이제는 열심히 코딩하는 일만 남았구나~~ ㅋㅋ

Git transport detail
Git transport

요기 사이트에서 발췌:

Git – setting up a remote repository and doing an initial ‘push’

There is loads of documentation and posts on Git out there so this is more of a note to self as I keep forgetting the steps to setting up a remote repository and doing an initial ‘push’.

So, firstly setup the remote repository:

mkdir my_project.git
cd my_project.git
git init --bare
git-update-server-info # If planning to serve via HTTP

On local machine:

cd my_project
git init
git add *
git commit -m "My initial commit message"
git remote add origin
git push origin master


Team members can now clone and track the remote repository using the following:

git clone
cd my_project
git-track origin

Note: the ‘git-track’ command is a bash function we use to save manually editing the .git/config file (add the following to your ~/.bash_profile file as outlined by darkliquid):

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
function git-track {
  git-config branch.$CURRENT_BRANCH.remote $1
  git-config branch.$CURRENT_BRANCH.merge refs/heads/$CURRENT_BRANCH

h4. Bonus

To have your terminal prompt display what branch you are currently on in green, add the following to your ~/.bash_profile:

function parse_git_branch_and_add_brackets {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
PS1="\h:\W \u\[33[0;32m\]\$(parse_git_branch_and_add_brackets) \[33[0m\]\$ "

댓글도 하나 참고

Instead of requiring the git-track function that you have created, you can just do this instead:

git push -u origin master

The remote branch is then automatically tracked. Thanks for the help creating my remote repo though :o )


  • Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s