linux mint上推送更新至github的设置,以及git使用(blog)
来源:互联网 发布:软件版权登记流程 编辑:程序博客网 时间:2024/06/06 00:40
环境
Linux Mint 17.3
git version 2.7.4
设置:
1.生成密钥对
penn@Linux-Mint18 ~ $ ssh-keygen -t rsa -C "xxxx@gmail.com"Generating public/private rsa key pair.Enter file in which to save the key (/home/penn/.ssh/id_rsa): Created directory '/home/penn/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/penn/.ssh/id_rsa.Your public key has been saved in /home/penn/.ssh/id_rsa.pub.The key fingerprint is:SHA256:xxxxxxxxxxxxxxxxxxxxxxxxx xxxx@gmail.comThe key's randomart image is:+---[RSA 2048]----+| ooo|| . . . ..|| . . . o . o .||E . .. o . + || . ...S o . || . =.+. o.|| + @.X . *|| . =.= +.B.o.|| . . ..++o |+----[SHA256penn@Linux-Mint18 ~ $ cd .sshpenn@Linux-Mint18 ~/.ssh $ lsid_rsa id_rsa.pubpenn@Linux-Mint18 ~/.ssh $ cat id_rsa.pub ssh-rsa xxxxxxxxxxxxxxxxxxxxxx xxxx@gmail.com
2.将公钥添加到github
3.检查配置结果
penn@Linux-Mint18 ~/.ssh $ ssh git@github.comThe authenticity of host 'github.com (192.30.253.113)' can't be established.RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxAre you sure you want to continue connecting (yes/no)? yPlease type 'yes' or 'no': yesWarning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.PTY allocation request failed on channel 0Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.Connection to github.com closed.
4.git全局配置
penn@Linux-Mint18 ~/.ssh $ git config --global user.name "xxxx"penn@Linux-Mint18 ~/.ssh $ git config --global user.email "xxxx@gmail.com"
5.创建本地git目录
penn@Linux-Mint18 ~/.ssh $ cd penn@Linux-Mint18 ~ $ cd Desktop/penn@Linux-Mint18 ~/Desktop $ cd github_projects/penn@Linux-Mint18 ~/Desktop/github_projects $ lspenn@Linux-Mint18 ~/Desktop/github_projects $ mkdir github_hexopenn@Linux-Mint18 ~/Desktop/github_projects $ lsgithub_hexopenn@Linux-Mint18 ~/Desktop/github_projects $ cd github_hexo/penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ lspenn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git init初始化空的 Git 仓库于 /home/penn/Desktop/github_projects/github_hexo/.git/
6.添加github远程仓库
penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git remote add github.io https://github.com/xxxx/xxxx.github.io.gitpenn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git remotegithub.io
7.拉取github项目到本地git目录
penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git fetch github.io 来自 https://github.com/xxxx/xxxx.github.io * [新分支] master -> github.io/masterpenn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git status位于分支 master
8.提交新文件到remote
penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ touch test.mdpenn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git status位于分支 master未跟踪的文件: (使用 "git add <文件>..." 以包含要提交的内容) test.md提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git add .penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git commit -m "test"[master 0fe3106] test 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.mdpenn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git status位于分支 master无文件要提交,干净的工作区penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git push -u github.io masterUsername for 'https://github.com': xxxxPassword for 'https://xxxx@github.com': To https://github.com/xxxx/xxxx.github.io.git ! [rejected] master -> master (non-fast-forward)error: 无法推送一些引用到 'https://github.com/xxxx/xxxx.github.io.git'提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。提示:再次推送前,先与远程变更合并(如 'git pull ...')。详见提示:'git push --help' 中的 'Note about fast-forwards' 小节。
9.解决冲突
penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git merge github.io/master -m "merge local to remote"Merge made by the 'recursive' strategy. 2016/06/12/hugo 1 use it in win7/index.html | 753 ++++++++++++++++++ 2016/06/14/hugo 2 update sidebar/index.html | 782 ++++++++++++++++++ ... ...penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ ls2016 archives categories commonweal favicon_32X32.ico images js README.md sitemap.xml test.md404.html atom.xml CNAME css google6f9ffd2313a65622.html index.html page robots.txt tags vendors
10.再次push到remote,成功
penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $ git push -u github.io masterUsername for 'https://github.com': xxxxPassword for 'https://xxxx@github.com': 对象计数中: 10, 完成.Delta compression using up to 8 threads.压缩对象中: 100% (5/5), 完成.写入对象中: 100% (10/10), 1.05 KiB | 0 bytes/s, 完成.Total 10 (delta 1), reused 2 (delta 0)To https://github.com/xxxx/xxxx.github.io.git 8d2d9fa..accb66c master -> master分支 master 设置为跟踪来自 github.io 的远程分支 master。penn@Linux-Mint18 ~/Desktop/github_projects/github_hexo $
11.git log
可以看当前git仓库的修改记录
git log 文件名 可以看指定文件或者文件夹的log
也可以在指定的文件夹内使用
git log ./ 也可以看执行此命令的文件夹的修改记录
git show 查看某次commit的修改内容
git log -p 查看某个文件的修改历史
git log -p -2查看最近2次的更新内容
git log –stat 查阅最近的提交修改
12.在某些情况下我们可能希望查看目标文件两个版本之间的差异。 查看这个文件任意两个版本的差异:
git diff <hashcode-before-right> <hashcode> <filename>
13.团队开发或者做Code Review的时你可能需要用到:
查看某个文件的包含提交人员,日期、版本号等记录信息,不包括修改详情:
git whatchanged <filename>
14.在review时查看某次提交修改详情:
git show <hashcode>
15.我们打算查看某个文件在某次提交中的修改:
git show <hashcode> <filename>
我们分析后发现不是这几次的修改造成的,所以我们希望查看这个文件所有的提交记录。
查看仅这个文件的所有历史记录:
git log --pretty=oneline <filename>
16.gitignore的使用
S1: touch .gitignore #创建gitignore隱藏文件 S2: vim .gitignore #编辑文件,加入指定文件 #下面是我的gitignore文件的内容 #忽略gitignore文件 .gitignore #忽略后缀名为.o和.a的文件 *.[oa] #显示指定忽略名称为main的文件 main 文件.gitignore的格式规范:A:#为注释 B:可以使用shell所使用的正则表达式来进行模式匹配 C:匹配模式最后跟"/"说明要忽略的是目录 D:使用!取反(例如目录中包含 test.a,并且gitignore文件中包含 *.[oa],如果在文件中加入 !test.a 表明忽略除test.a文件以外的后缀名为.a或者.o的文件)
0 0
- linux mint上推送更新至github的设置,以及git使用(blog)
- 使用git更新github上的开源项目
- Git使用—更新github上最新的代码至本地
- Git以及GitHub的使用
- 在mac上使用github--设置git
- 在mac上使用github--设置git
- 在android studio上使用git向github推送代码
- git安装以及对github上代码托管批处理更新
- GitHub上如何使用git工具以及git的使用命令
- Git的使用以及GitHub的配置
- Git的使用以及GitHub的配置
- Github以及git的使用操作
- 关于Git以及Github的使用
- git以及github的使用(1)
- Github客户端以及Git shell的使用
- Linux --- git的常用命令以及在github上获取,上传代码
- Linux---git的常用命令以及在github上获取,上传代码
- 使用Git管理GitHub上的项目
- java笔试+面试总结——java基础篇
- 如何正确理解和使用ES6 Promise?(We have a problem with promises)
- netty导致tomcat假死
- java——正则表达式整理
- C++运算符重载等
- linux mint上推送更新至github的设置,以及git使用(blog)
- Android studio 中使用svn
- PHP与MySQL的交互(mysqli)
- 改变TextView特定字符颜色及背景可正则匹配
- 上架详细流程
- Android 自动旋转屏幕快捷开关监听
- NOIP 2016.8第一次模拟总结
- leetcode_c++:Word Ladder II(126)
- 去耦电容器是否真的有必要?