git创建远程仓库以及在本地提交到远程仓库的方法
Posted georgemxx
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git创建远程仓库以及在本地提交到远程仓库的方法相关的知识,希望对你有一定的参考价值。
Git create remote repository and usage in the local environment
1. create the remote repository
loggin the server
$ cd ~/git/git_learn/
$ mkdir project.git
$ cd project.git
$ git init --bare
thus there are some files and directories in the directory ‘~/git/git_learn/project.git/‘, just like the following picture
and then you need to add the write access to this repository, so that you can git push in the local environment
$ cd ~/git/git_learn
$ chmod -R 777 project.git ( significant )
2. In your local environment, open ‘bash‘ shell, and initialize a local repository(git project)
$ cd ~/test
$ mkdir Myproject.git
$ git init
and the next step is to add new file or modify existing file, then commit them
$ vim main.c
$ git add main.c or git add .
$ git commit -s ( confirm the user.name and user.email are correct and available ) or git commit -m "create the project and add main.c"
$ git remote add origin george@10.168.101.104:/home/george/git/git_learn/project.git ( here please confirm the remote repository has write access )
$ git push origin master
以上是关于git创建远程仓库以及在本地提交到远程仓库的方法的主要内容,如果未能解决你的问题,请参考以下文章