如何将本地代码上传至git仓库

如题所述

注意:安装的前提条件是配置好Git的相关环境或者安装好git.exe,此处不再重点提及
上传的步骤:(本文采用git 命令界面进行操作)
( git config --global user.email "[email protected]"
git config --global user.name "Your Name")实现登陆
1.进入本地的项目目录,右键“Git Bash here”,调出git命令行界面,然后输入
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
git init
2.就是将目录下的所有文件上传,也可以将“.”换成具体的文件名
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
git add .
3.将项目提交到gitHub
[html] view plain copy 在CODE上查看代码片派生到我的代码片
git commit -m "注释语句"
4.在github上创建新的repository
5.点击 “Create repository”跳转到一个连接,如下红色圈获取到本项目的github地址
6.将本地的代码关联到github上
[html] view plain copy 在CODE上查看代码片派生到我的代码片
git remote add origin 项目的github地址
7.上传代码到github之前需要先pull
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
git pull origin master
8.上传代码到远程仓库
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
git push -u origin master
之后输入账号,密码,上传到github
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-07-29
首先我们在需要提交仓库或者下载代码的地方打开git bash命令,按照以下步骤依次进行

git init

git remote add origin 仓库名

git pull origin master

git branch 自己新创建的分支名

git checkout 自己新创建的分支名

git add '文件夹或者文件名'

git commit -a -m “描述信息”

git checkout master

git merge "自己新创建的分支名"

git push origin master

成功上传!~

git
merge命令用于合并指定分支到当前分支。

查看分支:git branch

创建分支:git branch <name>

切换分支:git checkout <name>

创建+切换分支:git checkout -b <name>

合并某分支到当前分支:git merge <name>

删除分支:git branch -d <name>本回答被网友采纳
相似回答