Git使用小結

Git使用小結

   流程:

      git基本操作

      git clone url克隆

      git add file更新

git rm log –r刪除文件夾

      git commit提交

      git push推送

      git pull拉取

      查看先前版本與回到現在

git log 

git reset --hard 要回到的commit字符串

回到未來:

git reflog 

git reset --hard 未來的commit字符串

合作開發——提交代碼

git checkout lhc轉到自己有權限的分支上

執行git基本操作

      查看狀態 git status

由於未將所有文件做版本控制,不能直接使用倉庫代碼覆蓋本地,所以採用如下方法:

git clean -n

顯示文件刪除情況

git clean -d -fx

刪除當前目錄及子文件夾下的未 track 的文件及文件夾

   問題

      1.git push -u origin master):

Username for 'https://icode.zhenrongbao.com': lihaicheng

Password for 'https://[email protected]':

fatal: unable to access 'https://icode.zhenrongbao.com/lihaicheng/test_gitlab.git/': The requested URL returned error: 500

使用httpshttp就可能出現這種問題,使用git就沒有

       之後的問題都是在使用https時發生的問題,不確定是不是git也會有

       2.git commit時發生問題

*** Please tell me who you are.

 

Run

 

  git config --global user.email "[email protected]"

  git config --global user.name "Your Name"

 

to set your account's default identity.

Omit --global to set the identity only in this repository.

 

fatal: unable to auto-detect email address (got 'zrb@bogon.(none)')

提交郵箱和姓名

git config --global user.email "[email protected]"

git config --global user.name "lihaicheng"

       多人合作的經驗      

1、多用客戶端和工具,少用命令行,除非是在Linux服務器上直接開發。——學習工具是爲了提升我們的工作效率,不是爲了研究工具本身

2、每次提交前,diff自己的代碼,以免提交錯誤的代碼

3、下班回家前,整理好自己的工作區

4、並行的項目,使用分支開發

5、遇到 衝突,搞明白衝突的原因,千萬不要隨意丟棄別人的代碼

6、產品發佈後,記得打tag,方便將來拉分支修bug

 

同步master中的數據

git pull origin master

       工作使用git的流程

git pull

git merge master

git add bin

git commit -m "刪除無用註釋,統一代碼風格"

git push

git stash

https://www.cnblogs.com/tocy/p/git-stash-reference.html

git pull origin master

git add bin

git commit -m "格式修復"

git push origin lhc

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章