文章出處
文章列表
最近幾天用到了git,作為只看過教程,沒有在實際項目中使用過的人來說,簡直是 T_T ......
在這里記錄一下,以防以后忘記。
- clone : 本地沒有該庫,從遠程repository拷貝到本地
- fetch : 本地有該庫,將遠程repository的新commit下載到本地
- pull : fetch + merge 操作,分開操作更安全
- 提交新的變更,一般的步驟是:
> git add . > git commit -m "new commit" > git push
- 同步fork項目原作者的改動:
// 查看fork庫的地址和原作者庫的地址 git remote -v // 獲取原作者最新版本 git fetch upstream // 如果當前不是master,切換到master git checkout master // 合并 git merge upstream/master
- 遇到的幾個問題:
- fatal: LF would be replaced by CRLF / fatal: LF would be replaced by CRLF : http://blog.csdn.net/lysc_forever/article/details/42835203
-
fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched. : 可能是由于 .git/config 中配置不當,搜到了這篇文章(http://www.myexception.cn/operating-system/1470149.html),筆者貼上了一個模板,如下:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = false [remote "origin"] url = https://github.com/CrossLee/xxx.git fetch = +refs/heads/*:refs/remotes/origin/* pushurl = https://github.com/CrossLee/xxx.git [branch "master"] remote = origin merge = refs/heads/master
其中 url pushurl 換成自己的項目地址。
文章列表
全站熱搜