git 應用指令紀錄
Copyright 2021, 月下麒麟 YMont
名詞解釋
定義
- master:本地分支名
- origin master:origin 表示遠端,master 表示分支名,接在 origin 之後表示是遠端分支名
- origin/master:遠端分支在本地的拷貝,因此稱為本地分支
範例
- git fetch origin master:取得遠端分支 master 的資料
- git merge origin/master:合併本地分支 origin/master 的程式碼
- git push origin master:將本地提交紀錄推至遠端分支 master
正常流程
git clone
git init
git add
修改檔案或是資料夾,就可以把變更紀錄存起來
git status
有被git add抓到的變更就會出現綠色字(Changes to be committed)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
沒有被git add抓到的,會出現紅色字(Changes not staged for committed)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
git commit
git remote
git push
成功的提示訊息 如下
除錯解法
git rm remote
錯誤描述
解決方法
rebase
rm .git
reference:How to upload a project to Github
git pull 與 git pull –rebase差異
git pull = git fetch + git merge against tracking upstream branch
git pull –rebase = git fetch + git rebase against tracking upstream branch
if you want to know how git merge and git rebase differ, following this.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Reference:Git: 四種將分支與主線同步的方法
重新pull & 再次commit
Debug1
新的一天要git pull,從遠端到本地,但是一直失敗
Command
git pull origin master
Error
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Debug
表示沒有連結到遠端的repository
git remote add origin http://192.168. ...
Debug2
因本地與遠端的內容不同,需要合併
Command
git pull --rebase
Error
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.
Debug
git add .
Debug3
Command
接著再試一次 >> git pull –rebase
git pull --rebase
Error
error: cannot pull with rebase: Your index contains uncommitted changes.
error: please commit or stash them.
Debug
所以要commit才可以
git commit -m "descriptation
reference:git–-如何解决git pull之后报错
reference:How to merge remote master to local branch