使用git关联项目
1 初始化项目
git init
2 关联到git仓库
git remote add origin git@github.com:projectGroupName/gitName.git
3 添加文件到仓库,添加全部文件用 . 表示
git add .
4 把文件提交到仓库
git commit -m " first add project file"
5 把文件提交到仓库
git push -u origin master //将本地的项目提交到远程仓库中。
git常见问题
1 解决“fatal: ‘origin’ does not appear to be a git repository…”
当使用Git进行代码push提交时,出现报错信息“fatal: ‘origin’ does not appear to be a git
repository…”, $ git push -u origin master fatal: ‘origin’ does not
appear to be a git repository fatal: Could not read from remote
repository.
是因为远程不存在origin这个仓库名称,可以使用如下操作方法,查看远程仓库名称以及路径相关信息,可以删除错误的远程仓库名称,重新添加新的远程仓库;
git remote -v: //查看远程仓库详细信息,可以看到仓库名称
git remote remove orign: //删除orign仓库(如果把origin拼写成orign,删除错误名称仓库)
git remote add origin 仓库地址: //重新添加远程仓库地址
gti push -u origin master: //提交到远程仓库的master主干
2 git查看用户名密码邮箱以及修改命令
git config user.name //查看用户名
git config user.password //查看查看密码
git config user.email //查看查看邮箱
git config --global user.name "xxxx(新的用户名)" //修改用户名
git config --global user.password "xxxx(新的密码)" //修改密码
git config --global user.email "xxxx@xxx.com(新的邮箱)" //修改邮箱
3 git在提交代码时候可能会出现(failed to push some refs to ‘xxxxxx’ …)
其实出现这个错误的原因是因为github中的README.md文件不在本地代码目录中,可以通过执行git pull --rebase origin master这个命令解决。
最后再执行git push -u origin master命令即可提交代码