GITHUB

作者: NamasAmitabha | 来源:发表于2017-12-19 20:32 被阅读0次

https://git-scm.com/book/zh/v2/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E7%94%9F%E6%88%90-SSH-%E5%85%AC%E9%92%A5#_generate_ssh_key

1 安装 Git
yum install git
Git 依赖的库
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
添加更多格式的文档
yum install asciidoc xmlto docbook2x

2 初次运行 Git 前的配置
git config --global user.name "HanBing"
git config --global user.email 1366054376@qq.com
git config --list
3 GitHub - 账户的创建和配置
Generating a new SSH key
ssh-keygen -t rsa -b 4096 -C "1366054376@qq.com"
Adding your SSH key to the ssh-agent
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
Adding a new SSH key to your GitHub account
cat < ~/.ssh/id_rsa.pub
In the upper-right corner of any page, click your profile photo, then click Settings.
n the user settings sidebar, click SSH and GPG keys.

SSH Key buttonClick New SSH key or Add SSH key. * n the user settings sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
Click Add SSH key.
If prompted, confirm your GitHub password.

Testing your SSH connection
ssh -T git@github.com

Working with SSH key passphrases
Adding or changing a passphrase
add below to ~/.bashrc
################################
env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }

agent_load_env

agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running

agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi

unset env
################################

4 GitHub - 维护项目
这里除了一个你必须要填的项目名,其他字段都是可选的。 现在只需要点击 “Create Repository” 按钮,Duang!!! – 你就在 GitHub 上拥有了一个以 <user>/<project_name> 命名的新仓库了
https://github.com/Aquariusjames/jtames
[root@localhost jtames]# mkdir practice
[root@localhost jtames]# cd practice/
[root@localhost practice]# git init
Initialized empty Git repository in /root/jtames/practice/.git/
[root@localhost practice]# git clone https://github.com/Aquariusjames/jtames
Cloning into 'jtames'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
[root@localhost practice]# git ls-remote https://github.com/Aquariusjames/jtames
128dadf545d9db0d5dc52b781329000c2c60758b HEAD
128dadf545d9db0d5dc52b781329000c2c60758b refs/heads/master

5 Git 基础 - 获取 Git 仓库
配置并初始化一个仓库(repository)、开始或停止跟踪(track)文件、暂存(stage)或提交(commit)更改。 本章也将向你演示如何配置 Git 来忽略指定的文件和文件模式、如何迅速而简单地撤销错误操作、如何浏览你的项目的历史版本以及不同提交(commits)间的差异、如何向你的远程仓库推送(push)以及如何从你的远程仓库拉取(pull)文件。
git init
$ git add *.c
$ git add LICENSE
$ git commit -m 'initial project version'
克隆现有的仓库
git clone https://github.com/libgit2/libgit2

6 Git Cheat Sheet
创建

复制一个已创建的仓库:

$ git clone ssh://user@domain.com/repo.git

创建一个新的本地仓库:

$ git init

本地修改

显示工作路径下已修改的文件:

$ git status

显示与上次提交版本文件的不同:

$ git diff

把当前所有修改添加到下次提交中:

$ git add .

把对某个文件的修改添加到下次提交中:

$ git add -p <file>

提交本地的所有修改:

$ git commit -a

提交之前已标记的修改:

$ git commit

附加消息提交:

$ git commit -m 'message here'

修改上次提交
<em>Don't amend published commits!</em>

$ git commit --amend

提交历史

从最新提交开始,显示所有的提交记录(显示hash, 作者信息,提交的标题和时间):

$ git log

显示所有提交(仅显示提交的hash和message):

$ git log --oneline

显示某个用户的所有提交:

$ git log --author="username"

显示某个文件的所有修改:

$ git log -p <file>

谁,在什么时间,修改了文件的什么内容:

$ git blame <file>

分支与标签

列出所有的分支:

$ git branch

切换分支:

$ git checkout <branch>

基于当前分支创建新分支:

$ git branch <new-branch>

基于远程分支创建新的可追溯的分支:

$ git branch --track <new-branch> <remote-branch>

删除本地分支:

$ git branch -d <branch>

给当前版本打标签:

$ git tag <tag-name>

更新与发布

列出对当前远程端的操作:

$ git remote -v

显示远程端的信息:

$ git remote show <remote>

添加新的远程端:

$ git remote add <remote> <url>

下载远程端版本,但不合并到HEAD中:

$ git fetch <remote>

下载远程端版本,并自动与HEAD版本合并:

$ git remote pull <remote> <url>

将远程端版本合并到本地版本中:

$ git pull origin master

将本地版本发布到远程端:

$ git push remote <remote> <branch>

删除远程端分支:

$ git push <remote> :<branch> (since Git v1.5.0)
or
git push <remote> --delete <branch> (since Git v1.7.0)

发布标签:

$ git push --tags

合并与重置

将分支合并到当前HEAD中:

$ git merge <branch>

将当前HEAD版本重置到分支中:

<em>Don't rebase published commit!</em>

$ git rebase <branch>

退出重置:

$ git rebase --abort

解决冲突后继续重置:

$ git rebase --continue

使用配置好的merge tool 解决冲突:

$ git mergetool

在编辑器中手动解决冲突后,标记文件为已解决冲突

$ git add <resolved-file>

$ git rm <resolved-file>

撤销

放弃工作目录下的所有修改:

$ git reset --hard HEAD

移除缓存区的所有文件(i.e. 撤销上次git add):

$ git reset HEAD

放弃某个文件的所有本地修改:

$ git checkout HEAD <file>

重置一个提交(通过创建一个截然不同的新提交)

$ git revert <commit>

将HEAD重置到上一次提交的版本,并放弃之后的所有修改:

$ git reset --hard <commit>

将HEAD重置到上一次提交的版本,并将之后的修改标记为未添加到缓存区的修改:

$ git reset <commit>

将HEAD重置到上一次提交的版本,并保留未提交的本地修改:

$ git reset --keep <commit>

http://www.jianshu.com/u/mr1Dbv
Command

git checkout

git status

git checkout -b

git commit

git diff

git add

git clean -fdx

git fetch --prune

git pull --ff-only

git branch -D

git push

git merge

git rm

git rebase

git reset

git revert

git push origin :yourbranch

Source:

Git Cheat Sheet
http://www.jianshu.com/p/c4ace9202a34

Git,Github和Gitlab简介和基本使用
http://www.jianshu.com/p/8d497989f704

Pro Git
https://git-scm.com/book/zh/v2
https://git-scm.com/book/en/v2

1.5 起步 - 安装 Git
https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git

Connecting to GitHub with SSH
https://help.github.com/articles/connecting-to-github-with-ssh/

相关文章

  • GitHub--加入GitHub

    上一篇我们讲述了GitHub的基本概念,下面我们来讲述如何创建GitHub用户。推荐阅读:GitHub--初识Gi...

  • GitHub--初识GitHub

    说老实话,我目前还是个GitHub菜鸟,哈哈!还处于从GitHub上面Clone代码的阶段。当初,只是不断听别人说...

  • Github Visualization / Github 数据

    [TOC] Github Visualization / Github 数据可视化 网站链接: https://s...

  • GitHub之初识GitHub

    GitBub是什么,我就不阐述了,那么,我开始吧。 1 创建账户 首先,打开GitHub,出现如下所示: 右侧上角...

  • Github平台 加入Github

    那么多的不说,我继续更新。 为了更好的使用Github,第一步去了解这个平台是重要的。 因此这篇我将针对Githu...

  • 【GitHub】我的GitHub

    应大家要求,已将前期一些代码传至GitHub。用户名:ququcai,地址:https://github.com/...

  • 【GitHub】GitHub的使用

    基本指令 配置自己的身份:git config -- global user.name "Tony"设置自己的名字...

  • [ github ] github clone private

    当前前提: 1: 拥有github登陆账号2: mac电脑 本文所述: 1: 创建一个新的私有工程2: 配置ssh...

  • github - github注册(一)

    前言 github面向开源及私有软件项目的 托管 平台github是 分布式 的 版本控制 系统微软收购githu...

  • Github

    1.在命令行中,输入“git init”,使Test文件夹加入git管理;2.输入“git add .”(不要漏了...

网友评论

      本文标题:GITHUB

      本文链接:https://www.haomeiwen.com/subject/gjiiwxtx.html