顯示具有 Git 標籤的文章。 顯示所有文章
顯示具有 Git 標籤的文章。 顯示所有文章

2013年10月25日 星期五

Git實際操作指令



  • git reset --hard HEAD~1  # 這將會回到上一個commit時的狀態,注意檔案也會re-update回、                                              去喔!小心使用  可搭配git commit log 來看看現在commit的狀                                                態,再還沒push之前都可以改commit!!



  • 建立新的branch 並切換到新的branch:
           #git branch test_new_branch
           #git checkout test_new_branch


  • 利用commit ID number 來回到某一次 log的狀態:
           #git reset "commit ID number"  
           (這裡注意其實只要比對前六個他就能夠批配到了, 不用一長串的全打.)







[GitHub相關] 使用git push 出現 "you can't push to git use https...." 的解決方式:


Git hub 前面基本設定之後,最後要git push xxxxxxxx  master 時,

出現以下:
fatal: remote error:
You can't push to git://github.com/my_user_name/my_repo.git
Use git@github.com:my_user_name/my_repo.git

原因是因為 git 是 Read-Only , 叫你使用https的方式存取,

故你若要使用 git 來做存取 , 你必須要打通SSH key 來加入到你的GitHub帳號,

照著以下簡單步驟做就可以使用git push 嚕



當然若你要使用https也是可以(就不用SSH key了),但是可能還是會有問題,會出現

"error: The requested URL returned error: 403 while accessing https://github.com/JackABK/rtenv.git/info/refs"

請參照這裡解決:


不過還是介意自己產生ㄧ組SSH key 加入到自己Git Hub帳號吧!!

2013年10月15日 星期二

Git基本指令

  • 基本指令
  1. git init  # 非常重要!! 有時候清除不小新加入的也可以重用這個!!
  2. git remote –s
  3. git remote –v
  4. git status
  5. git add kernel.c
  6. git commit –m “this function is very simple” #add commit string on GitHub
  7. git push origin master
  8. git remote add origin2 http://.............
  9. git push force (強制串改commit 紀錄)
  10. git stash
       Refer to :
        Git 初學筆記 - 實作測試:
       Jserv class: