通过git remote 建立远程仓库
建立远程仓库
1.初始化一个空的git仓库
创建一个文件夹,并进入
执行git init命令
如下显示:
Reinitialized existing Git repository in /home/moran/workspace/gitit/.git/
现在/home/moran/workspace/gitit目录就是git仓库了
2.向仓库提交我们写的文件
software@debian:~/yafeng$ echo "our first git repository" >> file
software@debian:~/yafeng$ ls
file
software@debian:~/yafeng$ git add file
software@debian:~/yafeng$ git commit -m "the first file to commit" file
[master (root-commit) 0c72641] the first file to commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file
software@debian:~/yafeng$
3.在本地仓库添加一个远程仓库,并将本地的master分支跟踪到远程分支
software@debian:~/yafeng$ git remote add origin ssh://software@172.16.0.30/~/yafeng/.git
software@debian:~/yafeng$ git push origin master
software@172.16.0.30's password:
Everything up-to-date
software@debian:~/yafeng$
4.测试
software@debian:~/yafeng$ git remote show origin
software@172.16.0.30's password:
* remote origin
Fetch URL: ssh://software@172.16.0.30/~/yafeng/.git
Push URL: ssh://software@172.16.0.30/~/yafeng/.git
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (up to date)
software@debian:~/yafeng$