Linux下git的使用--OSChina

来源:互联网 发布:solr数据没有了 编辑:程序博客网 时间:2024/05/16 04:51
1.先在git.oschina.net注册,并创建一个项目
项目语言 C,添加.gitignore C,开源许可证 GPL v2
2.虚拟机下操作
[luminqi@localhost ~]$ whereis git
git: /usr/bin/git /usr/share/man/man1/git.1.gz
说明原来有了git,可以用命令git --version查看版本,发现git版本为1.7.1,版本过低,我们要卸载旧版并安装最新的git,但是不要用yum安装,yum安装就会重新下1.7.1的版本,应该采用源码安装
[luminqi@localhost ~]$ sudo yum remove git
先安装依赖的包
[luminqi@localhost ~]$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
[luminqi@localhost ~]$ sudo wget https://www.kernel.org/pub/software/scm/git/git-2.9.3.tar.gz
上面是git软件包的地址,下载的是2.9.3的版本
[luminqi@localhost ~]$ tar zxvf git-2.9.3.tar.gz
[luminqi@localhost git-2.9.3]$ make prefix=/usr/local/git all 
生成git的帮助文档(man/info之类的)
[luminqi@localhost git-2.9.3]$ sudo make prefix=/usr/local/git install
[luminqi@localhost ~]$ vim ~/.bashrc
在最后添加export PATH=$PATH:/usr/local/git/bin
[luminqi@localhost ~]$ source ~/.bashrc
[luminqi@localhost ~]$ git --version
git version 2.9.3
[luminqi@localhost ~]$ git config --global user.name "lumqi"
[luminqi@localhost ~]$ git config --global user.email "958822582@qq.com"
[luminqi@localhost ~]$ ssh-keygen -t rsa -C "958822582@qq.com"
系统会提示key的保存位置(一般是~/.ssh目录)和指定口令,保持默认,连续三次回车即可。
[luminqi@localhost ~]$ vim ~/.ssh/id_rsa.pub
然后用vim打开该文件,id_rsa.pub文件内的内容,粘帖到OSChina帐号管理的添加SSH key界面中。

[luminqi@localhost ~]$ ssh -T git@git.oschina.net
The authenticity of host 'git.oschina.net (120.55.239.11)' can't be established.
RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.oschina.net,120.55.239.11' (RSA) to the list of known hosts.
Welcome to Git@OSC, lumqi!

[luminqi@localhost ~]$ mkdir my_git
[luminqi@localhost ~]$ cd my_git/
[luminqi@localhost my_git]$ git clone https://git.oschina.net/lumqi/myfl2440.git
[luminqi@localhost my_git]$ ls
myfl2440
[luminqi@localhost my_git]$ cd myfl2440/
[luminqi@localhost myfl2440]$ ls
LICENSE  README.md
初次添加文件:
[luminqi@localhost myfl2440]$ vim README.md
[luminqi@localhost myfl2440]$ git add README.md
[luminqi@localhost myfl2440]$ git commit -m "Edit by CentOS64"
[master 2e1a763] Edit by CentOS64
1 file changed, 2 insertions(+)
[luminqi@localhost myfl2440]$ git remote add origin https://git.oschina.net/lumqi/myfl2440.git
fatal: 远程 origin 已经存在。
[luminqi@localhost myfl2440]$ git remote rm origin
[luminqi@localhost myfl2440]$ git remote add origin https://git.oschina.net/lumqi/myfl2440.git
[luminqi@localhost myfl2440]$ git push -u origin master
(gnome-ssh-askpass:17155): Gtk-WARNING **: cannot open display:
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Username for 'https://git.oschina.net': lumqi

(gnome-ssh-askpass:17156): Gtk-WARNING **: cannot open display:
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Password for 'https://lumqi@git.oschina.net':
对象计数中: 3, 完成.
压缩对象中: 100% (2/2), 完成.
写入对象中: 100% (3/3), 272 bytes | 0 bytes/s, 完成.
Total 3 (delta 1), reused 0 (delta 0)
To https://git.oschina.net/lumqi/myfl2440.git
   dd83a1a..2e1a763  master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。
下次使用时:
[luminqi@localhost myfl2440]$ cp /home/luminqi/my_svn/fl2440test/trunk/src/linux-3.0.patch
[luminqi@localhost myfl2440]$ git add linux-3.0.patch
[luminqi@localhost myfl2440]$ git commit -m "add"
[luminqi@localhost myfl2440]$ git push origin master(不用-u)


参考博客:
http://www.cnblogs.com/zhcncn/p/4030078.html
0 0
原创粉丝点击