亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

第一次使用Git向Github推送代碼

標簽:
微服務 開源

首先要有一个Github账号,登录到Github新建一个仓库。

https://img3.sycdn.imooc.com/5fc59f61000185ef07340738.jpg

接下来下载GIt软件,Git官网为Git - Downloads (git-scm.com),下载完成,直接安装即可。

安装完成后,进入电脑本地需要推送的项目文件夹,右键选择git bash here

https://img4.sycdn.imooc.com/5fc5a1ab0001035606600241.jpg

第一次使用Git需要配置用户名和密码,使用如下命令:

git config --global user.name "username" #username为你在Github注册的用户名

git config --global user.email "[email protected]" #[email protected]为你在Github注册的邮箱

接下来:

①在Git里面输入git init

https://img3.sycdn.imooc.com/5fc5a4890001d8d208050088.jpg

②输入git add .此处注意有一个空格和.表示把该项目文件夹中所有文件提交到暂存区

https://img1.sycdn.imooc.com/5fc5a4ea0001937003320052.jpg

③输入git commit -m 'first commit',first commit表示第一次提交

https://img3.sycdn.imooc.com/5fc5a67f00018a5703240043.jpg

④输入git remote add origin git@https://github.com/ljihong/GhostNet-Flower.git,其中git@https://github.com/ljihong/GhostNet-Flower.git为你的Github项目的clone地址,可在

https://img3.sycdn.imooc.com/5fc5a7c9000181d211660288.jpg

你的GitHhub官网项目上查看,如上图位置,单击右侧按钮即可复制。

https://img1.sycdn.imooc.com/5fc5a8890001a15e08030066.jpg

⑤我使用网上的教程命令 git push -u origin master进行提交,结果报错!!!如下:

https://img4.sycdn.imooc.com/5fc5a91e0001a85b08060103.jpg

然后我在网上查阅了很多方法都没有得到解决,最后我发现别人在箭头所指地方为master:https://img2.sycdn.imooc.com/5fc5a9e90001b02108770158.jpg

而我的Git界面上此处位置为main:

https://img4.sycdn.imooc.com/5fc5aa5f0001163708060103.jpg

因此,我将git push -u origin master替换为git push -u origin main,上传成功:

https://img1.sycdn.imooc.com/5fc5aaa3000136d506710227.jpg

此时查看我GitHub官网上的项目,已经有了文件,推送代码成功:

https://img2.sycdn.imooc.com/5fc5ab04000150cf15470737.jpg

Git上传的五步命令总结:

git init

git add .

git commit -m 'first commit',first commit

git remote add origin git@https://github.com/ljihong/GhostNet-Flower.git

git push -u origin main


我这里是mian而不是master的原因:

我在待推送的项目上右键单击,选择了Git Bash Here:

https://img1.sycdn.imooc.com//5fc8482700010cce06800071.jpg

然后 git clone https://github.com/ljihong/GhostNet-Flower.git 把远程仓库克隆到了本地:

https://img1.sycdn.imooc.com//5fc84afa0001405108060202.jpg

因此在该项目文件夹中又多出来一个GhostNet-Flower文件夹:

https://img1.sycdn.imooc.com//5fc84a290001a5a406430247.jpg

然后我将该项目的所有文件都放进新出现的GhostNet-Flower文件夹,在Git工具中使用cd GhostNet-Flower命令进入该文件夹,就由master变成了main:

https://img1.sycdn.imooc.com//5fc84b9700011e5608050114.jpg

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
算法工程師
手記
粉絲
19
獲贊與收藏
4

關注作者,訂閱最新文章

閱讀免費教程

  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消