Git -- 创建一个远程git仓库和做初始化"push"

Origin: http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/

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

So, firstly setup the remote repository:

ssh [email protected]
mkdir my_project.git
cd my_project.git
git init --bare
git-update-server-info # If planning to serve via HTTP
exit


On local machine:

cd my_project
git init
git add *
git commit -m "My initial commit message"
git remote add origin [email protected]:my_project.git
git push origin master


Done!

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

git clone [email protected]:my_project.git
cd my_project
git-track origin

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

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function git-track {
  CURRENT_BRANCH=$(parse_git_branch)
  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\[\033[0;32m\]\$(parse_git_branch_and_add_brackets) \[\033[0m\]\$ "


---------------------------


    git config --global user.name "Your Name"
    git config --global user.email [email protected]


你可能感兴趣的:(function,command,git,documentation,Terminal,branch)