Git 设置远程仓库 初始化push 图文教程

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

There is a great deal of documentation and many posts on Git out there, so this is more of a note to self as I keep forgetting the steps needed to set up a remote repository and doing an initial “push”.

这里记录一下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 -u 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

Bonus

To have your terminal prompt display what branch you are currently on in green, add the following to your ~/.bash_profile (I have my current directory displayed in cyan):

function git-branch-name {    git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3  }  function git-branch-prompt {    local branch=`git-branch-name`    if [ $branch ]; then printf " [%s]" $branch; fi  }  PS1="[email protected]h [33[0;36m]W[33[0m][33[0;32m]$(git-branch-prompt)[33[0m] $ "

腾讯云限时秒杀【点击购买】

搬瓦工,CN2高速线路,1GB带宽,电信联通优化KVM,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ,支持<支付宝> 【点击购买】!

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】

Git 设置远程仓库 初始化push 图文教程

`微信`扫码 加好友

链接到文章: https://www.gkxyz.com/git-shezhiyuanchengcangku-chushihuapush-tuwenjiaocheng.html

推荐站点

评论已关闭