git提交本地仓库至远端

本地创建好项目之后,项目是在本地,此时,需要将本地的代码库提交至远端,下面是总结的一系列操作

1、创建完项目结构,没有分支

git add . --将创建的项目结构,添加至本地仓库
git commit -m “first-commit” 提交项目至本地仓库,此时就会创建出本地分支,master

2、在github上新建远程仓库

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

此时,远程仓库就创建完毕了

红色框中的第一个是远程仓库的地址,可以使用SSH 或 HTTP的方式提交

第二个是本地仓库提交至远程仓库的命令

3、按照上图中红色框中的命令,就可以提交本地

仓库至远端了
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:crzaywh/exercise-design-mode.git
git push -u origin master

4、提交过程中可能会遇到全局配置文件config 中没有配置用户和邮箱地址的情况

git config -l 
查看当前项目的本地config的配置,查看有没有不对的地方,进行更改

5、git pull,push每次都需要输入密码的问题解决

使用Git pull,push代码每次都需要输入密码的原因是在添加远程库的时候使用了https的方式。。所以每次都要用https的方式push到远程库;

1、查看下当前使用的传输协议:

git remote -v

origin https://github.com/tigerwow/exercise.git (fetch)
origin https://github.com/tigerwow/exercise.git (push)

2、重新设置成ssh的方式:

git remote rm origin
git remote add origin git@github.com:username/repository.git
git push -u origin 当前分支名
git remote -v

origin git@github.com:tigerwow/exercise.git (fetch)
origin git@github.com:tigerwow/exercise.git (push)
发布了45 篇原创文章 · 获赞 2 · 访问量 1万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章