git 代码托管html
去Git官网上下载安装便可git
$cd ~/.ssh //若是说没有这个目录,就直接看第三步
$ssh-keygen -t rsa -C "email"
("email" git帐号)
以后直接回车,不用填写东西。以后会让你输入密码。而后就生成一个目录.ssh ,里面有两个文件:id_rsa , id_rsa.pubgithub
用记事本打开id_rsa.pub文件,复制内容,在github.com的网站上到ssh密钥管理页面,添加新公钥,随便取个名字,内容粘贴刚才复制的内容。shell
而后把id_rsa.pub里的内容复制进去就能够了。
app
指令:ssh
$ git config --global user.name “your_username”
$ git config --global user.email “your_registered_github_Email”
ssh -T git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.ide
RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.测试
Are you sure you want to continue connecting (yes/no)? yes #确认你是否继续联系,输入yes网站
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.code
Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa': #生成ssh kye是密码为空则无此项,若设置有密码则有此项且,输入生成ssh key时设置的密码便可。
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出现此句话,说明设置成功。
git clone 地址
//先放进本地仓库 git add . git commit -m '本次提交备注' git status //查看仓库状态
git push
git pull //将当前分支绑定的远程分支的最新的修改拉取到本地,通常在咱们push以前都应该pull拉取一下查看是否有冲突
git reflog //回溯历史版本 git reset --hard //回溯到指定状态,只要提供目标时间点的哈希值
https://jingyan.baidu.com/article/48206aea68e69f216ad6b33f.html
git branch //显示分支一览表,同时确认当前所在的分支 git checkout -b aaa //建立名为aaa的分支,而且切换到aaa分支 (git branch aaa //建立名为aaa的分支 git checkout aaa // 切换到aaa分支)能和git branch -b aaa 获得一样的效果
git checkout <主分支> //先切换到合并的分支 git merge <被合并的分支> -m '填写一个合并的信息' //再将指定分支合并到当前分支 git push
查看当前已合并的和未合并过的分支,可见其余分支中没有合并的内容
git branch --merged git branch --no-merged
(参考)http://www.javashuo.com/article/p-aljjaxus-v.html
github上已经有master分支 和dev分支
在本地
git checkout -b dev // 新建并切换到本地dev分支 git pull origin dev //本地分支与远程分支相关联
在本地新建分支并推送到远程
git checkout -b test git push origin test //这样远程仓库中也就建立了一个test分支
error: Your local changes to the following files would be overwritten by merge: src/test/resources/application_context.xml Please, commit your changes or stash them before you can merge. Aborting
为解决此问题,作以下操做
git stash
隐藏本地修改
git pull
下载最新代码
git stash pop
从Git栈中读取最近一次保存的内容,恢复本身的本地修改
提示有无冲突
如有冲突,则解决冲突
若无,则直接提交
git add .
git commit -m "comments"
fatal: The current branch v2.0.6 has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin v2.0.6
复制执行便可
git push --set-upstream origin v2.0.6