1.前提:已经建立远程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.删除远程仓库文件(远程仓库与本地仓库已经建立关联)
git rm your file
git commit -m'delete yourfile'
git push
5.注意:以上的方法,会把远程仓库的最外层文件夹带来,产生的路径如下
/Users/yourMacName/Desktop/新建文件/yourProjectFiles/yourfile
3.不带仓库最外层的文件夹(图1和图2的区别)
1.初始化本地git仓库
git init
rm -rf .git//删除git init
2.关联远程仓库
方法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 "输入你的邮箱"//修改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在本地新建一个分支后,需要做远程分支关联。如果没有关联,git会在下面的操作中提示你显示的添加关联
//解决办法 已经在上面提示出来了
git push --set-upstream yourGit
- 如果
git pull
后 ,出现一下错误
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