mac os 使用git

http://blog.sina.com.cn/s/blog_4cd8dd130101mzmr.html


mac os  装 git总结

  (2013-06-28 16:31:14)
标签: 

杂谈

 

 

下载:http://code.google.com/p/git-osx-installer/

下载最新的PGK文件。

关闭xcode,安装pkg文件 ;然后运行脚本 setup_git_PATH.sh;

我安装时出现:Unable to find remote helper for 'httpshttps'错误

vim .git/config 去掉一个https就OK啦

PS:如果此处只有https,用下面的方法解决;

这是因为path没设置上  解决方法如下:

The git-osx-installer that you used should have installed git into /usr/local/git. See if you can cdinto that directory. If you can, then check that your PATH was correctly set by running echo $PATHfrom the terminal and making sure that you see /usr/local/git/bin in the included PATH. If not, you need to add it to your PATH.

Did you run the included shell script setup git PATH for non-terminal programs.sh?

Update 1: How to run the included shell script

  1. Mount the git-osx-installer disk image by double-clicking git-1.7.3.5-x86_64-leopard.dmg, which should be located in your Downloads folder.
  2. Open Terminal from /Applications/Utilities/Terminal
  3. Type cd /Volumes/Git 1.7.3.5 x86_64 Leopard/
  4. Type ./setup git PATH for non-terminal programs.sh and hit Enter to run the shell script. Note: Once you type ./setup you can hit the Tab key and it will autocomplete for you.
  5. Open a new Terminal and type echo $PATH
  6. Confirm that you see /usr/local/git/bin in your PATH.

Update 2: Show Git Who's the Master

Open Terminal and issue the following commands:

echo "/usr/local/git/bin" > git sudo mv git /etc/paths.d

When you run sudo it will ask for your OS X password.

After issuing those two commands, you should be able to open a new Terminal window and see/usr/local/git/bin when you run echo $PATH.

For this to work you have to have the following in /etc/profile, which it does by default:

if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi

在介绍安装和简单使用前,先看一下百度百科中的简介吧:


————————————————————————————————————————
    Git --- The stupid content tracker, 傻瓜内容跟踪器。
    Linux 是这样给我们介绍 Git 的:
    Git 是用于Linux 内核开发的版本控制工具。与常用的版本控制工具 CVS, Subversion 等不同,它采用了分布式版本库的方式,不必服务器端软件支持,使源代码的发布和交流极其方便。 Git 的速度很快,这对于诸如 Linux kernel 这样的大项目来说自然很重要。 Git 最为出色的是它的合并跟踪(merge tracing)能力。
————————————————————————————————————————
下面我用ubuntu 10.10上的命令为例:(这些命令都是在本地客户端处使用,非服务器操作裸库使用)
(本文中尖括号内包含尖括号都将是描述内容,请在输入实际命令时替换成描述内容所符的内容。)
1、安装:
$ sudo apt-get install git
sudo apt-get install gitk#此为安装官方的图形界面,不需要的可以不安装
 
2、cd到需要管理的代码、文件所在的第一级目录
 
3、初始化:
$ git init
 
4、添加当前目录所有内容:
$ git add .
 
5、查看状态:
$ git status
 
6、添加commit:
$ git commit -am "first commit."
 
7、版本对比:
$ git diff
 
8、查看历史记录:
$ git log
 
9、分支操作
查看分支:$ git branch
创建分支:$ git branch 分支名称 (注意:请不要在服务端建立分支)
切换分支:$ git checkout 分支名称
删除分支:$ git branch -d 分支名称
 
10、加入服务器
$ git remote add 用户名@计算机名或IP:~/某个目录
 
11、推送数据
$ git push master master #本地master推送到远端master
如果想快捷的使用git push就推送到默认远端分支master,可以做个一次性设置:
$ git remote add origin <实际的ssl用户名>@<IP地址>:<Git在远端的path>
    做完以上设置,以后直接使用git push 就会自动推送到上述设置地址了,但如果要推送到其他分支,还是需要加参数的,这个设置只是相当于一个默认参数而已。
 
12、接收数据
$ git pull origin master
如果想直接使用git pull直接接收,同样需要提前做一个一次性设置(同样也是不能应用多分支pull情况):
$ git branch --set-upstream master origin/master
 
13、本地库设置个人姓名和邮件
$ git config --global user.name "你的姓名,最好由没有符合和空格的英文字母组成"
$ git config --global user.email <邮件名>@<邮箱服务商后缀>
如果不设置个人信息,提交的信息将不会有更改者信息,这样会加大项目管理的难度。
 
14、启动图形界面
$ gitk
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值