git 拉取同步步驟


一、 同步幾種情況:

1、創建一個新倉庫
git clone git@****/test.git(或https://開頭的遠程url)
cd test  //進入本地項目目錄
touch README.md //新建介紹文檔
git add README.md //添加到git
git commit -m "add README" //本地提交
git push -u origin master //服務器提交
2、推送現有文件夾
cd existing_folder //進入本地項目目錄
git init //初始化
git remote add origin git@***/test.git //與服務器建立連接,要求服務器上是一個空的項目,只有項目名
git add . //將當前目錄下文件添加到git
git commit -m "Initial commit" //本地提交
git push -u origin master //將本地分支origin 提交到服務器master分支
3、推送現有的 Git 倉庫
cd existing_repo 
git remote rename origin old-origin //修改分支名稱
git remote add origin git@***/test.git //建立連接
git push -u origin --all //提交本地所有分支到服務器
git push -u origin --tags //提交本地帶標簽的分支到服務器

 

二、若干命令

git status     查看未提交本地以及本地未提交服務器的文件

git rm --cached [文件名]   在git中邏輯刪除,本地存在,只是git不跟蹤,記得git commit 提交一下

git rm -f [文件名]     強制刪除,本地還有git都刪除

git reset HEAD~1 回退上一步,不能回來,注意小波浪線是esc下面的鍵

git revert HEAD 撤銷更改,還能回來,有新節點記錄

git checkout 【newImage】  切換到新分支

 

三、報錯

git clone 報錯,原因 服務器未開啟ssh服務,22端口未開放

ssh: connect to host gitlab.app.guomeng.name port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 

git push 報錯,原因服務器限制了上傳文件的大小,修改下服務的配置,比如私搭的服務器gitlab的配置

fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
Everything up-to-date

 

git push報錯,方案刪除項目下的.git文件夾,重新init來過

fatal: unable to access 'https://***/test.git/': Port number ended with 'y'

 

四、推薦個學習git的網站,圖形化命令,形象記憶

git學習

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM