第一次使用 gitbash
2016-01-04 12:09
447 查看
此方法是自己开发时用的, 所以只有master一个分支
1. 安装gitbash. 下载地址: https://git-for-windows.github.io/.
2. 一些配置(可跳过)
http://blog.csdn.net/u011526234/article/details/50352135
3. 注册 github 账号,
4并添加私钥.(可查看网站文档或自行百度)
配置 SSH KEYS
要使用SSH协议连接 GITHUB,首先需要生成 SSH KEYS。生成的密钥是两个文件,一个公钥一个私钥。公钥需要提交给GITHUB 官网您的账号中。关于如何生成 SSH Keys,请看如下步骤示例:
检查 SSH keys
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
生成 keys
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
然后按照提示输入密码,最后出现如下提示则说明生成成功。
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
将生成的新秘钥加入 SSH 客户端
# start the ssh-agent in the background
$ ssh-agent -s
# Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
复制公钥
复制公钥可以打开文件复制,也可以使用命令,建议使用命令复制,否则可能出现无法授权的问题。如下命令:
$ clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
将公钥加入到 GITHUB 账号
登录 GITHUB 在 Settings->SSH keys 菜单下添加,将剪切板的内容粘贴到 Key 文本框中,名称可以随意填写。到现在为止,配置工作已经完成。
5. 创建远程仓库.
在 https://github.com 中创建仓库()
6. 创建本地仓库并关联远程仓库(或者克隆远程仓库 git clone)
创建目录, 例如: f:/test,
使用 gitbash 进入test 目录, 执行命令 git init , 初始化仓库.
关联远程仓库, git remote add origin xxx(仓库地址)
添加文件, git add -A (全部添加) 添加指定文件, git add text.txt
本地提交: git commit -m "注释"
推送到远程仓库: git push -u origin master
由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。
1. 安装gitbash. 下载地址: https://git-for-windows.github.io/.
2. 一些配置(可跳过)
http://blog.csdn.net/u011526234/article/details/50352135
3. 注册 github 账号,
4并添加私钥.(可查看网站文档或自行百度)
配置 SSH KEYS
要使用SSH协议连接 GITHUB,首先需要生成 SSH KEYS。生成的密钥是两个文件,一个公钥一个私钥。公钥需要提交给GITHUB 官网您的账号中。关于如何生成 SSH Keys,请看如下步骤示例:
检查 SSH keys
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
生成 keys
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
然后按照提示输入密码,最后出现如下提示则说明生成成功。
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
将生成的新秘钥加入 SSH 客户端
# start the ssh-agent in the background
$ ssh-agent -s
# Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
复制公钥
复制公钥可以打开文件复制,也可以使用命令,建议使用命令复制,否则可能出现无法授权的问题。如下命令:
$ clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
将公钥加入到 GITHUB 账号
登录 GITHUB 在 Settings->SSH keys 菜单下添加,将剪切板的内容粘贴到 Key 文本框中,名称可以随意填写。到现在为止,配置工作已经完成。
5. 创建远程仓库.
在 https://github.com 中创建仓库()
6. 创建本地仓库并关联远程仓库(或者克隆远程仓库 git clone)
创建目录, 例如: f:/test,
使用 gitbash 进入test 目录, 执行命令 git init , 初始化仓库.
关联远程仓库, git remote add origin xxx(仓库地址)
添加文件, git add -A (全部添加) 添加指定文件, git add text.txt
本地提交: git commit -m "注释"
推送到远程仓库: git push -u origin master
由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。
相关文章推荐
- shell date cal
- shellcode
- /bin/bash^M: bad interpreter: 没有那个文件或目录
- spark-submit 和 spark-shell 后面可跟的参数
- .bash_profile和.bashrc以及profile的什么区别
- Bash shell programming 函数返回值
- shell命令
- linux shell 中文件编码查看及转换方法
- Shell学习 之 变量赋值和引用
- shell bad substitution
- Linux中用shell获取昨天、明天或多天前的日期
- -bash: ulimit: pipe size: cannot modify limit: Invalid argument
- Shell 的string 操作
- linux下node-webkit自动跨平台打包shell
- 写hive sql和shell脚本时遇到几个蛋疼的问题!
- linux shell数据重定向(输入重定向与输出重定向)详细分析
- adb shell ,出错 提示error: device not found
- 希尔排序(Shell's Sort)的C语言实现
- 在shell脚本中调用另一个脚本的三种不同方法(fork, exec, source)
- shell编程基础