码迷,mamicode.com
首页 > 其他好文 > 详细

git客户端常用命令

时间:2016-09-29 20:43:47      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

<?php
[root@www root]#ntpdate time.windows.com && hwclock -w  
[root@www root]#yum install curl curl-devel  
 
[root@www root]#yum install git
  
[root@www root]#mkdir git
 
[root@www root]#ssh-keygen -t rsa -C "269724033@qq.com" 
[root@www root]#ls -lah ../
[root@www root]# ../.ssh/id_rsa.pub 
[root@www root]# ssh -T git@github.com 
[root@www root]# git clone https://github.com/269724033/yaf.git 
 
  
[root@www root]#git config --list 
[root@www root]#git commit -m "first commit" 
  
添加
[root@www root]#git init
[root@www root]#git add README.md tiny.conf LICENSE core/ app/
[root@www root]#git remote set-url origin git@github.com:269724033/tiny.git 
[root@www root]#git commit -m "first commit"  ## git push origin master
[root@www root]#git push -u origin master

修改  git checkout .
[root@www root]#git init
[root@www root]#git clone https://github.com/269724033/yaf.git
[root@www root]#git remote set-url origin git@github.com:269724033/tiny.git  
[root@www root]#git checkout .                        #####先迁原项目代码;
[root@www root]#git add README.md tiny.conf LICENSE core/ app/      ###把新增的 或者修改的 都add过来 
[root@www root]#git commit -m "first commit"  ##  如果遇到提示列表 说no changes added to commit 任何更改 或 新加文件 都要 git add 。。。。。。
[root@www root]#git push -u origin master  ## 或者  git push origin master   或者   git push --all


删除
[root@www root]#git init 
[root@www root]#git remote set-url origin git@github.com:269724033/tiny.git 
[root@www root]#git remote rm main.php
[root@www root]#git commit -m "first commit"
[root@www root]#cd  yaf/目录
[root@www root]#git push --all


 



一些可能遇到的问题解决:
如果输入$ git remote add origin git@github.com:269724033/tiny.git
提示出错信息:fatal: remote origin already exists.
解决办法如下:
1、先输入$ git remote rm origin
2、再输入$ git remote add origin git@github.com:269724033/tiny.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"]那一行删掉就好了!

如果输入$ ssh -T git@github.com 
出现错误提示:Permission denied (publickey).因为新生成的key不能加入ssh就会导致连接不上github。
解决办法如下:
1、先输入$ ssh-agent,再输入$ ssh-add ~/.ssh/id_key,这样就可以了。
2、如果还是不行的话,输入ssh-add ~/.ssh/id_key 命令后出现报错Could not open a connection to your authentication agent.解决方法是key用Git Gui的ssh工具生成,这样生成的时候key就直接保存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令行来做。
3、最好检查一下在你复制id_rsa.pub文件的内容时有没有产生多余的空格或空行,有些编辑器会帮你添加这些的。
如果输入$ git push origin master
提示出错信息:error:failed to push som refs to …….
解决办法如下:
1、先输入$ git pull origin master //先把远程服务器github上面的文件拉下来
2、再输入$ git push origin master
3、如果出现报错 fatal: Couldn’t find remote ref master或者fatal: ‘origin’ does not appear to be a git repository以及fatal: Could not read from remote repository.
4、则需要重新输入$ git remote add  git@github.com:269724033/tiny.git




使用git在本地创建一个项目的过程
$ makdir ~/hello-world    //创建一个项目hello-world
$ cd ~/hello-world       //打开这个项目
$ git init             //初始化
$ touch README
$ git add index.php        //更新README文件
$ git commit -m first commit     //提交更新,并注释信息“first commit”
$ git remote add index.php git@github.com:269724033/tiny.git     //连接远程github项目
$ git push -u origin master     //将本地项目更新到github项目上去

 

git客户端常用命令

标签:

原文地址:http://www.cnblogs.com/sixiong/p/5920838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!