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 2141 Can you find it?【二分查找是否存在ai+bj+ck=x】
Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate ...
- Centos6.5安装mysql5.7详解
最近在linux上面安装mysql5.7上真是遇到了很多坑,真是让人头疼,在这里跟大家简单分享一下流程跟注意的地方. 1.查看linux版本是6.5 cat /etc/redhat-release 2 ...
- Javascript 行为委托
JavaScript 与C++,Java的面相对象编程的语言不同.就像不懂Linux人,会创造一个蹩脚的linux一样.一些JavaScript的编程总在尝试利用JavaScript 去模拟传统的面向 ...
- 4、Flask实战第4天:自定义url转换器
url传参可以限定参数的数据类型,例如:限定user_id数据类型为int @app.route('/user/<int:user_id>') def my_list(user_id): ...
- 进程注入后门工具Cymothoa
进程注入后门工具Cymothoa Cymothoa是一款隐秘的后门工具.它通过向目标主机活跃的进程注入恶意代码,从而获取和原进程相同的权限.该工具最大的优点就是不创建新的进程,不容易被发现.由于该 ...
- 【三分】Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) B. The Meeting Place Cannot Be Changed
三分显然,要注意EPS必须设成1e-6,设得再小一点都会TLE……坑炸了 #include<cstdio> #include<algorithm> #include<cm ...
- 【块状树】【LCA】bzoj1787 [Ahoi2008]Meet 紧急集合
分块LCA什么的,意外地快呢…… 就是对询问的3个点两两求LCA,若其中两组LCA相等,则答案为第三者. 然后用深度减一减什么的就求出距离了. #include<cstdio> #incl ...
- Intellij IDEA自动生成serialVersionUID
[Setting]->[Inspections]->[Serialization issues]->[Serializable class without ’serialVersio ...
- Oracle RAC 环境下的 v$log v$logfile
通常情况下,在Oracle RAC 环境中,v$视图可查询到你所连接实例的相关信息,而gv$视图则包含所有实例的信息.然而在RAC环境中,当我们查询v$log视图时说按照常理的话,v$log视图应当看 ...
- 使用Spring Cloud Sleuth和Zipkin进行分布式链路跟踪
原文:http://www.cnblogs.com/ityouknow/p/8403388.html 随着业务发展,系统拆分导致系统调用链路愈发复杂一个前端请求可能最终需要调用很多次后端服务才能完成, ...