mac使用git管理Github
来源:互联网 发布:pl sql developer下载 编辑:程序博客网 时间:2024/06/06 07:32
工欲善其事,必先利其器。
在OS X Yosemite 10.10.3安装最新版本Xcode,在terminal下可以发现git已经被安装。
12~ mesut$ git --version
git version
2.3
.
2
(Apple Git-
55
)
之前就已经注册并且使用Github了,不过一直都是在window 系统下远程管理。现在开始设置Mac管理Github,有一点需要知道的是本地的git仓库和Github服务器之间是通过ssh加密的。
在终端执行
12345678910ozil: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
123456ozil: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
1ssh-keygen -t rsa -C youremail
@example
.com(你的Github登陆名)
接着都是回车,选择默认的目录,默认的密码即可
1234567Generating
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的秘钥对123ozil:~ mesut$ cd .ssh
ozil:.ssh mesut$ ls
id_rsa id_rsa.pub
2:在Github设置ssh key
登陆Github, “Settings”->SSH keys->Add SSH key
title:可以顺便填名字
key:在Key文本框里粘贴
id_rsa.pub
文件的内容点击add key 配置完成
3:测试本地是否和Github连接上
史蒂夫
第一次链接Github,会有一个确认,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入1234ozil:.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
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
1234567891011121314151617181920212223242526272829ozil: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</mesut
@ozil
.local>
首先在本地初始化一个git仓库
由于之前没有配置用户名,所以首次commit会有提示,自动建立设置方式
12$ git config --global user.name Your Name
$ git config --global user.email email
@example
.com
为了把本地库推到远程服务器,首先需要在Github上面也建一个项目
在Repository name填上我们的项目名字,description随便填,别的默认。
然后会生成项目
然后把远程项目和本地库关联
123456789ozil: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.
so far so good~
- mac使用git管理Github
- mac使用git管理Github
- git mac github 使用
- mac使用git管理Github以及生成 SSH 公钥
- Mac使用git/github小结
- Mac使用git/github小结
- Mac下从安装Git到使用github进行版本控制(git命令/Xcode管理)
- Mac升级git版本 以及 使用git和github管理自己的项目---基础操作学习
- Mac下从安装Git到使用github进行版本控制(git命令/Xcode管理)
- 使用git管理github项目
- 使用git管理github项目
- 使用git管理github项目
- 使用git管理github项目
- 使用git管理github项目
- 使用git管理github项目
- 使用git管理github项目
- mac 使用git管理项目
- 在mac上使用github--设置git
- leetcode 166. Fraction to Recurring Decimal
- 关于UEditor配合TP框架使用
- 3.5模拟赛题解
- 神经网络的简单数学解释
- SpringAop
- mac使用git管理Github
- [重拾]深入理解gulp自动化
- CodeForces 106C Buns (01beoba)
- Java的反射机制详解
- Android开发问题汇总–持续更新
- Threading Performance 2
- linux学习笔记
- LeetCode OJ刷题历程——Remove Nth Node From End of List
- C++扬帆远航——1