mac使用git管理Github
工欲善其事,必先利其器。
在OS X Yosemite 10.10.3安装最新版本号Xcode。在terminal下能够发现git已经被安装。
~ mesut$ git --version
git version 2.3.2 (Apple Git-55)
之前就已经注冊而且使用Github了,只是一直都是在window 系统下远程管理。
如今開始设置Mac管理Github,有一点须要知道的是本地的git仓库和Githubserver之间是通过ssh加密的。
在终端运行
ozil:tmp mesut$ ssh -v
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-e escape_char] [-F configfile]
[-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-W host:port] [-w local_tun[:remote_tun]]
[user@]hostname [command]
明显Mac已经安装了ssh。
1:创建SSH Key
ozil:tmp mesut$ cd ~
ozil:~ mesut$ pwd
/Users/mesut
ozil:~ mesut$ cd .ssh
-bash: cd: .ssh: No such file or directory
ozil:~ mesut$
进入当前的用户文件夹。波浪线表示的是当前文件夹。
推断是否已经安装了.ssh,避免默认安装会覆盖之前安装的。
明显当前文件夹没有该文件
运行创建 ssh key
ssh-keygen -t rsa -C "youremail@example.com"(你的Github登陆名)
接着都是回车,选择默认的文件夹,默认的password就可以
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/mesut/.ssh/id_rsa):
Created directory '/Users/mesut/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/mesut/.ssh/id_rsa.
Your public key has been saved in /Users/mesut/.ssh/id_rsa.pub.
接着能够在用户主文件夹里找到.ssh文件夹,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH
Key的秘钥对
ozil:~ mesut$ cd .ssh
ozil:.ssh mesut$ ls
id_rsa id_rsa.pub
2:在Github设置ssh key
登陆Github, “Settings”->"SSH keys"->"Add SSH key"
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
title:能够顺便填名字
key:在Key文本框里粘贴id_rsa.pub文件的内容
点击add key 配置完毕
3:測试本地是否和Github连接上
史蒂夫
ozil:.ssh mesut$ ssh -T git@github.com
The authenticity of host 'github.com (xxx)' can't be established.
RSA key fingerprint is xxx.
Are you sure you want to continue connecting (yes/no)? yes
第一次链接Github,会有一个确认。须要你确认GitHub的Key的指纹信息是否真的来自GitHub的server,输入yes回车就可以。
Warning:
Permanently added 'github.com,xxx' (RSA) to the list of known hosts.Hi tanchongshi! You've successfully authenticated, but GitHub does not provide shell access.
4:使用git在本地建立的项目更新到Github
ozil:githubspace mesut$ mkdir hellogithub
ozil:githubspace mesut$ cd hellogithub/
ozil:hellogithub mesut$ ls -ah
. ..
ozil:hellogithub mesut$ git init
Initialized empty Git repository in /Users/mesut/Documents/githubspace/hellogithub/.git/
ozil:hellogithub mesut$ ls -ah
. .. .git
ozil:hellogithub mesut$ touch newfile
ozil:hellogithub mesut$ ls
newfile
ozil:hellogithub mesut$ git add newfile
ozil:hellogithub mesut$ git commit -m 'first commit'
[master (root-commit) 2295d3e] first commit
Committer: >v< <mesut@ozil.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file: git config --global --edit After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 newfile
首先在本地初始化一个git仓库
因为之前没有配置username。所以首次commit会有提示。自己主动建立
设置方式
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
为了把本地库推到远程server,首先须要在Github上面也建一个项目
在Repository name填上我们的项目名字。description随便填,别的默认。
然后会生成项目
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
然后把远程项目和本地库关联
ozil:hellogithub mesut$ git remote add origin git@github.com:tanchongshi/hellogithub.git
ozil:hellogithub mesut$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'XXX' to the list of known hosts.
Counting objects: 3, done.
Writing objects: 100% (3/3), 217 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:tanchongshi/hellogithub.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
https://github.com/tanchongshi/hellogithub
so far so good~
mac使用git管理Github的更多相关文章
- (数据科学学习手札67)使用Git管理Github仓库
一.简介 Git是目前使用最广泛的分布式版本控制系统,通过Git可以方便高效地管理掌握工作过程中项目内容文件的更新变化情况,通过Git我们可以以命令行的形式完成对Github上开源仓库的clone,以 ...
- mac 设置 git 和github 告别命令行
针对和我一样的新手,大虾们请轻拍. 很多小伙伴都想用git管理自己的代码,或者想在github上上传自己的项目.在网上找了几篇这方面的文章,都是用命令行设置的. 用命令行管理和安装太坑爹,这里有一个简 ...
- 使用git管理github上的项目
使用git可以把我们的项目代码上传到github上面去,方便自己管理,如何使用git?觉得是每位程序猿所必需要有的谋生技能,所以在此记录一下自己学会使用的这个过程: 一.需要注册github账号,这样 ...
- mac OS git关联github
正在更新 mac OS 默认安装了git git -v 查看版本 mac OS 默认安装了ssh ssh -v 查看版本 1.设置username和email(github每次commit都会记录 ...
- windows下使用git管理github项目
1. 下载安装msysgithttp://code.google.com/p/msysgit/downloads/list2. 注册github账号3. 生成ssh公钥和私钥ssh-keygen -C ...
- 「git」mac下git提交github代码
1.打开终端,输入 cd -/.ssh 这个是检查你的ssh的是否存在的,如果存在,先将已有的ssh备份,或者将新建的ssh生成到另外的目录下(如果第一次配置一般都是不存在的),不存在,你将会看到如下 ...
- 使用git管理github上的代码
第一次接触git是使用git来提交自己的github的代码,在new repository之后,github会给出一些操作示例. 示例如下: …or create a new repository o ...
- mac下git连接github远程仓库
git配置 一.安装git 官方网站下载安装,如果有安装homebrew,在终端输入brew install git,安装后的位置在/Users/计算机用户名目录下安装完成后,在终端输入git --v ...
- Mac下git通过SSH进行免密码安全连接github
Git——The stupid content tracker(傻瓜内容跟踪器) Git是Linux的缔造者Linus Torvalds为了帮助管理Linux内核源码而开发的一款免费.开源的分布式版本 ...
随机推荐
- HDU 1285 确定比赛名次【字典序最小的拓扑排序 + 优先队列】
确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submis ...
- python debug小技巧&&工程能力的几点建议
Debug小技巧: 转载请声明本文的引用出处:仰望大牛的小清新 1.初次编程时,在每一个if后面都写上else,这样,如果你的else原本是不应该运行的,那么就可以在else中输出此时的状态信息便于排 ...
- 洛谷——P1088 火星人
P1088 火星人 题目描述 人类终于登上了火星的土地并且见到了神秘的火星人.人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法.这种交流方法是这样的,首先,火星人把一个非常 ...
- 洛谷——P2958 [USACO09OCT]木瓜的丛林Papaya Jungle
P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer ...
- centos7下配置samba,win10访问
yum install -y samba samba-client 更改配置 [root@abcd mnt]# cat /etc/samba/smb.conf [global] workgroup = ...
- oracle tablespace usage status
select a.tablespace_name, a.bytes / 1024 / 1024 "Sum MB", (a.bytes - b.bytes) / 1024 / 102 ...
- 【bzoj1296】【[SCOI2009]粉刷匠】多次背包dp及小小的优化
先放题面 Description windy有 N 条木板需要被粉刷. 每条木板被分为 M 个格子. 每个格子要被刷成红色或蓝色. windy每次粉刷,只能选择一条木板上一段连续的格子,然后涂上一种颜 ...
- 在Code First中自动创建Entity模型
之前我在博客文章中介绍过如何使用Code First来创建数据库,通过CodeFirst的方式,可以大幅的减少开发人员的工作量,比传统的先创建库再ORM的方式简单了不少.但是,很多时候,特别是一些MI ...
- Debian安装VirtualBox增强工具
切换到root用户: apt-get install build-essential 或者 apt-get install gcc make apt-get install dkms apt-get ...
- jenkins报错 not a queue url
使用Python的jenkinsapi执行job时报错:not a queue url 虽然任务还是构建了,但是错误还是处理的. 原因是:Jenkins的配置,和jenkinsapi里的配置的URL内 ...