曾經忘過的git操作,以後要做一個真心的人

git 命令備忘

1. 自定義輸入用戶密碼clone項目:
	git clone https://user:[email protected]

git回退

  1. 先獲取要回退的版本號,eg:aaa
    git reset --hard aaa
    hard的方式會丟棄本地做出的所有修改和服務器保持一致,並將head指針指向回退的版本號;
  2. 此時可以有兩種操作:
    a. 直接暴力提交:git push -f orgin
    這種提交方式回退部分的日誌記錄會消失;


    b. 重置head指針到回退前的版本號, eg: bbb
    git reset --mixed bbb
    mixed這種方式不會放棄本地修改,將head指針指向指定版本號;
    然後直接push即可: git push orgin
    這種方式會保持回退的提交記錄,更利於版本變遷的管理;

git中同時向多個遠程倉庫推送

  1. 新增一個本地倉庫;
  2. 定義一個遠程倉庫a;
  3. 進入倉庫的.git文件夾中, 打開 config 文件;修改如下:
<!-- 該文件已是完成修改的版本,在remote下新增url即可,這樣不配置多個遠程倉庫的好處是:
僅一次提交就可以同時維護多個倉庫的代碼,使之保持一致 -->
[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[branch "master"]
	remote = orgin
	merge = refs/heads/master
[remote "orgin"]
	url = https://github.com/xxx/aaa.git
	url = https://gitee.com/xxx/aaa.git
	fetch = +refs/heads/*:refs/remotes/orgin/*

git 常見問題彙總

  1. 克隆項目提示如下:SSL certificate problem: self signed certificate in certificate chain
Administrator@liag MINGW64 /d/code
$  git clone https://user:[email protected]
Cloning into '9x40'...
fatal: unable to access 'https://xxxxxx.git': 
SSL certificate problem: self signed certificate in certificate chain

解決方法:執行git config --global http.sslVerify false 關閉SSL認證;

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