码迷,mamicode.com
首页 > 其他好文 > 详细

使用git在github上创建新工程

时间:2018-09-23 13:36:16      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:项目   因此   git init   目的   直接   文档   too   from   init   

这段时间进经常会忘记如何在github上同步工程,于是又得查资料,查参考书,浪费了很长时间,因此有了感触,写几篇有关此类问题的篇章!

这是老手新手都十分容易犯的错误,就是在创建一个新github项目或者以本地已有项目为原型重新创建一个github项目时,容易创建一个空文件夹就直接关联远程仓库,这样做只会返回错误!!!所以,文件夹一定不能为空......

创建新工程需要的命令

完成本地项目与git的关联


cd 工程目录
git init    //初始化本地仓库,当前目录下会出现一个名为 .git 的目录
git add .    //将所有文件添加到缓存区,告诉 Git 开始对这些文件进行跟踪
git commit -am "Hello"    //提交文件到本地仓库

完成远程项目的创建

在github上创建某个项目,然后可以拷贝处该项目的地址

关联远程仓库(github上创建的地址)


git remote add origin https://github.com/Introspelliam/Hello.git    //关联远程仓库

push本地项目到远程仓库


git push origin master     //push项目到master
Username for ‘https://github.com‘: //你的github账户名称

github上提供的工程创建方法

…or create a new repository on the command line

echo "# ctf-challenges" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Introspelliam/ctf-challenges.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin https://github.com/Introspelliam/ctf-challenges.git
git push -u origin master

 参考文档:https://introspelliam.github.io/2017/06/30/tools/%E4%BD%BF%E7%94%A8git%E5%9C%A8github%E4%B8%8A%E5%88%9B%E5%BB%BA%E6%96%B0%E5%B7%A5%E7%A8%8B/

使用git在github上创建新工程

标签:项目   因此   git init   目的   直接   文档   too   from   init   

原文地址:https://www.cnblogs.com/dylancao/p/9692188.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!