利用github管理项目小记

  一、建立仓库

    在github中建立项目仓库。

  二、克隆仓库到本地

    1、先确认认证的公钥是否正确(详细步骤自行谷歌一下)。在这里小毛用的是gitshell,命令行敲入:

1 ssh -T git@github.com

    

    正确则显示类似如下的结果:

 1 Hi maoguy! You've successfully authenticated, but GitHub does not provide shell access. 

    然后克隆你的github仓库,敲入如下指令:

1 git clone https://github.com/maoguy/IoT.git

    克隆成功后将有包含如下提示的一堆字符:

 1 Receiving objects: 100%  

  三、将你的项目push上github

    1、cd进入你的项目文件夹。

    2、敲入如下指令:

1   git add .
2   git commit -m 'commit'
3   git remote add origin https://github.com/maoguy/IoT.git
4   git push origin master

    3、若上传成功,终端则有如下输出:

1 Counting objects: 1281, done.
2 Delta compression using up to 4 threads.
3 Compressing objects: 100% (1188/1188), done.
4 Writing objects: 100% (1281/1281), 1.88 MiB | 25.00 KiB/s, done.
5 Total 1281 (delta 231), reused 0 (delta 0)
6 remote: Resolving deltas: 100% (231/231), completed with 1 local objects.
7 To https://github.com/maoguy/IoT.git
8    40cbb3d..dab8f18  master -> master

  

  四、其他指令

常用git命令
clone项目
git clone git@github.com:[group]/[projecct].git

查看工作区状态
git status
pull代码
git pull origin [branch]
push代码
git push origin [branch]
创建并切换分支
git checkout -b [branch]
切换分支
git checkout [branch]
查看分支
git branch
添加文件到暂存区
git add [file]
添加所有文件到暂存区
git add .
从暂存区提交到本地仓库
git commit -m "[comment]"
从暂存区还原到工作区
git reset [commit-id] [file]
从工作区还原到版本库
git checkout -- [file]
查看修改内容
git diff [file]
查看日志
git log -[the number of recent commits]

  

  五、END

    随着年纪越来越大,脑子也是从脑残逐渐升级为重度脑残,希望将一些生活的简单小细节记录下来,以备日后回顾。

    谢谢!

原文地址:https://www.cnblogs.com/maoguy/p/5862728.html