Git 常用操作

Posted 小蜗爬爬

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git 常用操作相关的知识,希望对你有一定的参考价值。


第一次传数据:
echo "# miya" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/zhao520a1a/miya.git
git push -u origin master


分支操作:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>


看不到git远程分支??
先用fetch命令更新remote索引。
$ git fetch
再查看remote分支,发现已经可以看到目标分支branch170628_foo。
$ git branch -a
 

提示出错信息:fatal: remote origin already exists.
    解决办法如下:
    1、先输入$ git remote rm origin
    2、再输入$ git remote add origin [email protected]:djqiang/gitdemo.git 就不会报错了!
    3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section ‘remote.origin‘. 我们需要修改gitconfig文件的内容
    4、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
    5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!

以上是关于Git 常用操作的主要内容,如果未能解决你的问题,请参考以下文章

git中常用的操作命令有哪些?常用操作命令归纳

Git常用操作命令

Git常用操作

GIT常用操作命令收集

Git工程开发实践——Git常用操作

Git常用操作