通过git remote 建立远程仓库

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24228375/article/details/50749964

通过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://[email protected]/~/yafeng/.git
software@debian:~/yafeng$ git push origin master
[email protected]'s password: 
Everything up-to-date
software@debian:~/yafeng$ 

4.测试

software@debian:~/yafeng$ git remote show origin
[email protected]'s password: 
* remote origin
 Fetch URL: ssh://[email protected]/~/yafeng/.git
 Push  URL: ssh://[email protected]/~/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$ 

猜你喜欢

转载自blog.csdn.net/qq_24228375/article/details/50749964