git/github 学习笔记

本文详细介绍如何在GitHub上创建一个新的项目并进行基本的操作,包括初始化本地项目、提交更改及同步到远程仓库等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建一个项目========================

  1. 回到github首页,点击页面右下角“New Repository”

填写项目信息:

project name: hello world

description : my first project

点击“Create Repository” ; 现在完成了一个项目在github上的创建。

  1. 我们需要使用git在本地创建一个相同的项目。

复制代码

$ makdir ~/hello-world    //创建一个项目hello-world
$ cd ~/hello-world    //打开这个项目
$ git init    //初始化 
$ touch README
$ git add README   //更新README文件
$ git commit -m 'first commit'//提交更新,并注释信息“first commit” 
$ git remote add origin git@github.com:defnngj/hello-world.git   //连接远程github项目  
$ git push -u origin master   //将本地项目更新到github项目上去

复制代码
现在查看github上面的hello world 项目,是不是发现已经将本地中的README文件更新上来了。 :) 恭喜!

————————————关于可能出现的错误———————————-

1.在执行

$ git remote addorigin git@github.com:defnngj/hello-world.git

错误提示:fatal: remote origin already exists.

解决办法:

$ git remote rm origin

然后在执行:$ git remote add origin git@github.com:defnngj/hello-world.git 就不会报错误了

  1. 在执行

$ git push origin master

错误提示:error:failed to push som refs to…….

解决办法:

$ git pull origin master // 先把远程服务器github上面的文件拉下来,再push 上去。

转载于:http://www.cnblogs.com/fnng/archive/2011/08/25/2153807.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值