美文网首页
git提交本地项目到github

git提交本地项目到github

作者: A_Tomato | 来源:发表于2019-08-29 14:14 被阅读0次
    你的本地仓库由 git 维护的三棵“树”组成。第一个是你的 工作目录,它持有实际文件;第二个是 暂存区(Index),它像个缓存区域,临时保存你的改动;最后是 HEAD,它指向你最后一次提交的结果

    1.进入项目根路径,通过git init创建新的仓库

    git init
    

    2.把当前项目添加到暂存区

    git add .             
    

    3.把文件提交到仓库,这样改动已经提交到了 HEAD,但是还没到远端仓库

    git commit -m "代码提交信息"     //例如:git commit -m "first"
    

    4.设置邮箱和名称

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
    
    

    5.关联远程仓库并获取远程库与本地同步合并

    git remote add origin https://github.com/**/**.git
    git pull --rebase origin master
    

    6.将这些改动提交到远端仓库,可以把 master 换成你想要推送的任何分支(远程仓库有可能需要输入账号密码)

    git push -u origin master    
    git status                     //查询状态        
    

    相关文章

      网友评论

          本文标题:git提交本地项目到github

          本文链接:https://www.haomeiwen.com/subject/xrfiectx.html