github新手使用说明

说在前面的话

准备开始学dajango建站,教程看了几页就说建议用github做版本控制,所以有了这个文章。

首先要清楚,git是一个版本控制软件,github是一个类似云盘一样的存代码的网站。如果你要从本机上传单个文件到github,可以一个一个上传,但如果你要上传完整项目到github,只能用git这个软件去弄。这里就说说怎么弄。
大致的步骤是:

1.在github上创建账号。
2.在账号内创建一个代码仓库。
3.往代码仓库里面放东西,之后就可以不断更新。这里会用到git。

一. 创建github账号

注册网址:https://github.com/join
完成后登陆。

二. 创建代码仓库

在个人主页的设置里面或类似地方的右上角加号位置可以建仓库,如下图:
在这里插入图片描述

在这里插入图片描述

三. 仓库使用

在仓库页面如下图:很简单,空空如也
在这里插入图片描述
要使用仓库,首先先下一个GIT上传软件:https://git-scm.com/downloads
安装完成后在其目录下有个git bash,打开来。
在这里插入图片描述
1.初始化本地项目目录
3个bash命令简单介绍一下
git help :获取git帮助,如 git help add
cd : 进入文件夹,如cd d:\hello, 可以设置默认目录 cd /D/hello 注意盘名字一定要是大写。如不输入这个语句 不给git bash定位的话,默认的本地文件位置是在c盘中.
ls: 遍历目录

通过cd进入到需要上传的代码目录中,然后git init 初始化目录

dsn059@DSN059 MINGW64 /d/hello/code
$ git init
Initialized empty Git repository in D:/hello/code/.git/

2.关联本地库和网络库
git remote add origin https://github.com/timebreaker123/learning-dajango.git
这里换成你自己的网址

dsn059@DSN059 MINGW64 /d/hello/code (master)
$ git remote add origin https://github.com/timebreaker123/learning-dajango.git

3.添加需要上传的文件,下图是上传所有文件,如是单个文件则可以直接加文件名,如git add test.py

dsn059@DSN059 MINGW64 /d/hello/code (master)
$ git add .

4.确认上传,可以加备注,如“cc”
git commit -m “cc”

dsn059@DSN059 MINGW64 /d/hello/code (master)
$ git commit -m "cc"
[master (root-commit) d0bd76b] cc
 Committer: dsn059 <dsn059@kyodoyushi.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
    git config --global --edit
After doing this, you may fix the identity used for this commit with:
    git commit --amend --reset-author
 1 file changed, 97 insertions(+)
 create mode 100644 test.py

5.最后一步推送,输入git push -u origin master,这是把代码上传到github仓库的意思。
然后会出现弹窗让你输入github用户名和密码,完成后可以确认是否上传成功。

dsn059@DSN059 MINGW64 /d/hello/code (master)
$ git push -u origin master
libpng warning: iCCP: cHRM chunk does not match sRGB
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 1.27 KiB | 651.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/timebreaker123/learning-dajango.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值