Git 版本控制說明





Git 概念

Git 錯誤訊息意思

bash提示符的工作方式

Associating text editors with Git

Git內部細節和如何生成提交ID

macOS下Terminal指令

文件比對

在Windows底下
FC  舊文件  新文件
在Linux或macOS底下
-u 標準別格式 使輸出內容更容易閱讀
diff  -u  舊文件 新文件

git 語法
see log   %git log
see last log%git log -n 1
exit git's log%q
get source%git clone url
get color in editor%git config --global color.ui auto
back to previous version%git checkout version_id
view the status of git%git status
discards any changes in either the working directory or the staging area%git reset --hard
view the different between staging area and the most recent commit%git diff staged
compare the working directory to the staging area%git diff
離開分離狀態的HEAD%git checkout master

view branches%git branch
create new branches%git branch branches_name
switched branch%git checkout branch_name
create new branches and switched branch%git checkout -b new_branch_name
view the git setting  %git config --list
to see remoto branch % git checkout branches_name


直觀圖像化的看出提交的歷史紀錄 %git log --graph --oneline branch_name1 branch_name2 ......

merge two branch together %git merge branch_name1 branch_name2

git merge說明

當commit是從其他branch merge過來的時候,想查詢原本branch的前一筆 %git show commit_id

%git branch -d branch_name
(-d means delete)

Git command review

Compare two commits, printing each line that is present in one commit but not the other.
git diff will do this. It takes two arguments - the two commit ids to compare. 
Make a copy of an entire Git repository, including the history, onto your own computer.
git clone will do this. It takes one argument - the url of the repository to copy. 
Temporarily reset all files in a directory to their state at the time of a specific commit.
git checkout will do this. It takes one argument - the commit ID to restore. 
Show the commits made in this repository, starting with the most recent.
git log will do this. It doesn't take any arguments.

Git基本設定
使用Sublime Text3編輯
window指令 %git config --global core.editor "'C:/Program Files/Sublime Text /sublime_text.exe' -n -w"
mac指令 %git config --global core.editor "open -a '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' --args -n -w"
(Sublime Text中間不要加\)
-n means Sublime will open in a new window
-w means git will wait for you to close Sublime before trying to continue.
單獨打git config --global core.editor "'/Applications/Sublime Text.app' -n -w" 會出現Aborting commit due to empty commit message. 


可另外加上這行,確保git執行sublime
當打開Terminal(終端機)後發現會出現-bash: __git_ps1: command not found
則需調整.bash_profile內容 >> 詳細方法

將 git-completion.bash,git-prompt.sh, .bash_profile放到git讀取設定檔案的目錄下

to enable tab completion.
window %mv Downloads/git-completion.bash.txt git-completion.bash
mac %cp Downloads/git-completion.bash /User/eddy/

one to enable the git features in the prompt.
window %mv Downloads/git-prompt.sh.txt  git-prompt.sh
mac %cp Downloads/git-prompt.sh /User/eddy/
window %mv Downloads/bash_profile_course   .bash_profile
mac %cp Downloads/.bash_profile /User/eddy/





參考資料來源
https://classroom.udacity.com/courses/ud775/lessons/2980038599/concepts/29937485730923
http://therobinkim.com/using-sublime-text-to-write-your-git-commit-messages/
https://classroom.udacity.com/courses/ud775/lessons/2969618657/concepts/29892386280923

No comments:

Post a Comment