本地项目上传到github

1、进入项目文件夹,使用git init命令把这个项目变成git可以管理的仓库

cd my-project
git init

2、把文件添加到版本库中,使用命令git add . 添加到暂存区里面去,后面的小数点“.”,表示添加文件夹下所有的文件

git add .

3、用命令git commit 把文件提交到仓库。

git commit -m "commit the change to the git repository"

4、关联到远程库

git remote add origin 远程库地址

例如:

git remote add origin https://github.com/CassieXue/my-project

5、获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)

git pull --rebase origin master

6、把本地库的内容推送到远端,实际上把当前分支master推送到远程。

git push -u origin master

状态查询命令:

git status

push过程中报错:error: You have not concluded your merge (MERGE_HEAD exists).

原因可能是在以前pull下来的代码自动合并失败

解决方法:保留本地更改,终止合并->重新合并->重新拉取

git merge --abort
git reset --merge
git pull

原文地址:https://www.cnblogs.com/xuepei/p/8377316.html