假如文件中找不到.git文件办绝,基本說(shuō)明是隱藏了.git文件夾
1.顯示隱藏文件夾
defaults write com.apple.finder AppleShowAllFiles -bool true
2.重啟finder
option+command+esc
創(chuàng)建本地庫(kù)
1?薪介、?創(chuàng)建文件夾?=?》然后?git init?(在內(nèi)部會(huì)生成?.git?文件夾)
2?辈讶、創(chuàng)建文件?=?》cd到要提交的項(xiàng)目中 = 》然后?git add(暫緩區(qū))=?》?git commit ?(提交區(qū))场航,經(jīng)過(guò)兩個(gè)布綴九妈。先到暫緩區(qū)再提交凯楔。
git status 查看
git log 杳看版本日志哪审。
git add readme.md?為?readme?文件本地建版本
git commit -m "readme for this project"?增加注釋
3?饶深、?如上圖所示的步驟?:git remote rm origin=?》?git remote add url(記住這個(gè)URL就是我們?cè)诜?wù)器中的地址餐曹,我們?cè)趙eb端手動(dòng)創(chuàng)建的庫(kù)?)=》git push;到此本地庫(kù)已經(jīng)同步到遠(yuǎn)程庫(kù)敌厘,
git remote rm origin?遠(yuǎn)端?url origin?是否存在
git remote add origin?https://git.oschina.net/yukige88/yukitest.git?創(chuàng)建遠(yuǎn)端url
git push -u origin master
env GIT_SSL_NO_VERIFY=true git push origin master
4?台猴、查看下web端https://git.oschina.net/yukige88/yukitest.git 已經(jīng)增加了readme.md文件到遠(yuǎn)程代碼庫(kù)中。
創(chuàng)建遠(yuǎn)程庫(kù)
1? 注冊(cè)github帳號(hào)俱两。
2?新建遠(yuǎn)程庫(kù)饱狂。
3?配置
錯(cuò)誤解決方法
一、如:qiuzhongweideMacBook-Pro:TestGit qiuzhongwei$ git commit ?On branch master
新建分支 git branch new
二宪彩、Git 提示fatal: remote origin already exists 錯(cuò)誤解決辦法
1?先刪除遠(yuǎn)程倉(cāng)庫(kù)?git remote rm origin
2休讳、再添加遠(yuǎn)程 Git 倉(cāng)庫(kù)?git remote add originh ttps://github.com/scottlove0519/GuoKongYiTiHua.git
三,Git 提示error: failed to push some refs to 'https://github.com/scottlove0519/GuoKongYiTiHua.git'
$ git fetch
$ git merge
試了尿孔,依然不行
偶然用百度的方法
把當(dāng)前分支代碼上傳到指定分支上
$ git push -u origin develop
因?yàn)檫M(jìn)行子多次提交俊柔,需要合并
git pull origin master --allow-unrelated-histories
四、error: Your local changes to the following files would be overwritten by merge:
1? ?git stash
2?git pull origin master --allow-unrelated-histories
3?git stash pop
然后可以使用git diff -w +文件名 來(lái)確認(rèn)代碼自動(dòng)合并的情況.
反過(guò)來(lái),如果希望用代碼庫(kù)中的文件完全覆蓋本地工作版本.?方法如下:
git reset --hard
git pull 從遠(yuǎn)程庫(kù)把更改的合并到當(dāng)前分支中活合。
git fetch origin 從遠(yuǎn)程庫(kù)
4?First, rewinding head to replay your work on top of it...
git clean -d -fx ""
git push origin master
git fetch和git pull的區(qū)別
git fetch:相當(dāng)于是從遠(yuǎn)程獲取最新版本到本地雏婶,不會(huì)自動(dòng)合并。
Shell
以上命令的含義:
首先從遠(yuǎn)程的origin的master主分支下載最新的版本到origin/master分支上
然后比較本地的master分支和origin/master分支的差別
最后進(jìn)行合并
上述過(guò)程其實(shí)可以用以下更清晰的方式來(lái)進(jìn)行:
Shell
2.?git pull:相當(dāng)于是從遠(yuǎn)程獲取最新版本并merge到本地
Shell
上述命令其實(shí)相當(dāng)于git fetch?和?git merge
在實(shí)際使用中白指,git fetch更安全一些留晚,因?yàn)樵趍e