GitHub Note

Figure 1. working directory 工作区 and repository 版本区(stage/index暂存区 和 分支matser). 指针Head指向当前分区. [1]

 

  • git 追踪些什么[1]

1)TXT文件,网页,所有的程序代码
2)图片、视频这些二进制文件,虽然也能由版本控制系统管理,但没法跟踪文件的变化,只能把二进制文件每次改动串起来,也就是只知道图片从100KB改成了120KB,但到底改了啥,版本控制系统不知道

3)不要使用Windows自带的记事本编辑任何文本文件。原因是Microsoft开发记事本的团队使用了一个非常弱智的行为来保存UTF-8编码的文件,他们自作聪明地在每个文件开头添加了0xefbbbf(十六进制)的字符,你会遇到很多不可思议的问题。建议下载Notepad++代替记事本,不但功能强大,而且免费!记得把Notepad++的默认编码设置为UTF-8 without BOM即可

 

  • Set username and user email

git config --global user.name "your user name"
git config --global user.email "your email address"

 

  • Begin in the local PC

cd ‘target folder path’  #go to the target working directory
pwd  #get current working directory
git status (if fatal, run ‘git init’ to create a git repository first)
git add .  #add all files/accept all changes
git commit –m “message for this commit”

 

  • roll back to previous version or return to the ‘future’ version

git log #可以查看提交历史,以便确定要回退到哪个版本
git reset –hard commit_id
git reflog  #查看命令历史,以便确定要回到未来的哪个版本
git diff HEAD -- filename  #check the difference of the file in working directory and repository
git checkout -- filename #roll back to the file in stage(暂存区)
git reset HEAD filename  #roll back to current version in repository, that is give up the version in stage

 

  • Authentication through SSH [3]

step1: ssh –keygen –t rsa #generate ssh key in local computer 
step2: Add SSH key to GitHub
step3: ssh –T git@github.com   #check whether it is successful

 

  • connect local repository to the remote repository in GitHub

step1: set up a repository in GitHub[Note: Set as private]
step 2: git bash in the local PC:
git remote add origin git@github.com:***.git [Go to the target repository in GitHub and get this name]
git push -u origin master #the first time, master分支和远程的master分支关联起来
git push origin master #Synchronize your repository in GitHub when the repository in your local PC is updated 

 

  • How to delet git

直接手动删去该文件夹下的.git文件夹,再‘git status’ 即发现仓库不存在了

 

Reference:

[1] https://www.liaoxuefeng.com/wiki/896043488029600 廖雪峰git教程

[2] https://guides.github.com/activities/hello-world/ GitHub Guides 10 minute

[3] 从零开学GitHub.pdf author: stormzhang

 

转载于:https://www.cnblogs.com/OrangeStand/p/10964207.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值