GitHub Note

Figure 1. working directory 工做區 and repository 版本區(stage/index暫存區 和 分支matser). 指針Head指向當前分區. [1]git

 

  • git 追蹤些什麼[1]

1)TXT文件,網頁,全部的程序代碼
2)圖片、視頻這些二進制文件,雖然也能由版本控制系統管理,但無法跟蹤文件的變化,只能把二進制文件每次改動串起來,也就是隻知道圖片從100KB改爲了120KB,但到底改了啥,版本控制系統不知道github

3)不要使用Windows自帶的記事本編輯任何文本文件。緣由是Microsoft開發記事本的團隊使用了一個很是弱智的行爲來保存UTF-8編碼的文件,他們自做聰明地在每一個文件開頭添加了0xefbbbf(十六進制)的字符,你會遇到不少難以想象的問題。建議下載Notepad++代替記事本,不但功能強大,並且免費!記得把Notepad++的默認編碼設置爲UTF-8 without BOM便可bash

 

  • Set username and user email

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

 

  • 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」ide

 

  • 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 ui

 

  • 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 successfulthis

 

  • 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

相關文章
相關標籤/搜索