2020年2月18日 星期二

本機基礎Git指令init,add,commit

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

初始化

git init

提交

git add .

加入控管

git commit -am "紀錄內容"

創造分支
git branch "branch_name"

進入分支
git checkout "branch_name"

創造並進入分支
git co -b "branch_name"

刪除分支
git branch -d "branch_name"

彩色顯示
git config --global color.ui true

簡寫
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch

美化Git lg顯示
git config --global alias.lg "log --graph --pretty=format:'%Cred%h - %Cgreen[%an]%Creset -%C(yellow)%d%Creset %s %C(yellow)<%cr>%Creset' --abbrev-commit --date=relative"

86400秒免輸入帳號密碼可pull/push

git config --global credential.helper 'cache --timeout 86400'

方式

git add [档案名称] (单个档案) 或 git add . (全部档案)
git reset HEAD 取消一次的add
git commit -m "这次存档的讯息"
git push origin master (上传到 github)

沒有留言:

張貼留言

cloud9上面開發rails

 使用IAM身分登入,以免有資安問題。(用admin帳號登入,創建iam使用者,然後在上面的連結登入) 選擇 ubuntu18.04 減少查詢成本。 已經是超級使用者了,sudo 什麼都不需要輸入密碼了。 $ ruby -v  檢查 ruby使用的版本>>2.6.3,...