1.前提:已經(jīng)建立遠程coding倉庫
2.git命令行的正常使用
1.遠程倉庫coding克隆到本地
cd /Users/yourMacName/Desktop/新建文件
git clone https://coding.net/yourusername/projectname.git
2.本地倉庫添加文件,并提交到遠程倉庫
git add yourfile
git commit -m'your message'
git push
3.遠程倉庫有更新樟遣,同步到本地倉庫
git pull
4.刪除遠程倉庫文件(遠程倉庫與本地倉庫已經(jīng)建立關(guān)聯(lián))
git rm your file
git commit -m'delete yourfile'
git push
5.注意:以上的方法寒匙,會把遠程倉庫的最外層文件夾帶來,產(chǎn)生的路徑如下
/Users/yourMacName/Desktop/新建文件/yourProjectFiles/yourfile
3.不帶倉庫最外層的文件夾(圖1和圖2的區(qū)別)
圖1
圖2
1.初始化本地git倉庫
git init
rm -rf .git//刪除git init
2.關(guān)聯(lián)遠程倉庫
方法1:直接替換遠程倉庫連接
cd /Users/yourMacName/Desktop/測試版
git remote set-oldURL origin <newURL>
方法2:先刪后加
cd /Users/yourMacName/Desktop/測試版
git remote rm origin
git remote add origin https://coding.net/yourProject/test
方法3:修改config文件
cd /Users/yourMacName/Desktop/測試版
git remote -v:顯示當前所有遠程庫的詳細信息
git config -e
3.push,pull,delete操作
git add yourfile
git commit -m'your message'
git push
git rm yourfile
git commit -m'delete yourfile'
git push
git pull
4.其他命令行
git config --global user.name 'your Name'
git config --global user.email 'your Email'
git config --list //查看config
git config --global --replace-all user.email "輸入你的郵箱"http://修改email/name/password
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
//使用git在本地新建一個分支后,需要做遠程分支關(guān)聯(lián)萨西。如果沒有關(guān)聯(lián)市框,git會在下面的操作中提示你顯示的添加關(guān)聯(lián)
//解決辦法 已經(jīng)在上面提示出來了
git push --set-upstream yourGit
- 如果
git pull
后 ,出現(xiàn)一下錯誤
From https://e.coding.net/tucici/SkyLineSDK
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
- 解決:
git branch --set-upstream-to=origin/master master
(master為遠程默認分支的名稱键耕,) - 如果爆錯:
fatal: branch 'master' does not exist
。
解決:git pull origin master --allow-unrelated-histories
:git pull origin V1.1 --allow-unrelated-histories
- 報錯
error: The following untracked working tree files would be overwritten by merge: .DS_Store
柑营。
解決:git clean -d -fx
git pull origin master --allow-unrelated-histories