git clone https://github.com/sunriseLe/MavenHadoopPlugin.git
-b branchName
指定具体分支:git clone -b test https://github.com/sunriseLe/MavenHadoopPlugin.git
git add .
提交信息
改为自己想要添加的说明信息:git commit -m "提交信息"
$ git push -u origin master
Username for 'https://github.com': sunriseLe
Password for 'https://[email protected]':
...
参考链接:
使用git将项目上传到github(最简单方法)
ignoreFile
替换为自己不想上传的某些。比如,这是一个idea生成的工程,可以忽略.idea
文件夹。git rm -r --cached ignoreFile
gedit .gitignore
readme.md
文件,通过git rm -r --cached readme.md
先删除缓存,然后.gitignore
的文件内容如下:readme.md
github
中没有了readme.md
文件,多了我们刚刚添加的.gitignore
文件。git add .
git commit -m "ignore readme.md"
git push -u origin master
$ git checkout -b dev
切换到一个新分支 'dev'
git checkout -b
相当与先创建新分支,再切换到新分支:$ git branch dev
$ git checkout dev
*
号的分支表示当前分支,对本地库所做的修改都会显示在当前分支上。$ git branch
* dev
master
test
git add .
git commit -m "dev branch add readme.md"
git push -u origin dev
参考链接:
创建与合并分支
git add .
添加本地修改。git pull
命令取回远程主机某个分支的更新,再与本地的指定分支合并:$ git pull https://github.com/sunriseLe/MavenHadoopPlugin.git dev
$ git add .
$ git commit -m "add log to show add tx history to db"
[bft-test e08d6ef] add log to show add tx history to db
1 file changed, 4 insertions(+), 2 deletions(-)
$ git push -u origin bft-test
Username for 'https://github.com': sunriseLe
Password for 'https://[email protected]':
To https://github.com/...
! [rejected] bft-test -> bft-test (non-fast-forward)
error: 推送一些引用到 'https://github.com/...' 失败
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 'git pull ...')。详见
提示:'git push --help' 中的 'Note about fast-forwards' 小节。
$ git pull https://github.com/... bft-test
Username for 'https://github.com': sunriseLe
Password for 'https://[email protected]':
来自 https://github.com/...
* branch bft-test -> FETCH_HEAD
自动合并 peer/db/leveldb.go
Merge made by the 'recursive' strategy.
peer/channel/config.go | 3 +++
peer/db/leveldb.go | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
$ git push -u origin bft-test
Username for 'https://github.com': sunriseLe
Password for 'https://[email protected]':
...
分支 'bft-test' 设置为跟踪来自 'origin' 的远程分支 'bft-test'。
git fetch origin
git merge origin/xxx # xxx表示自己想要合并的远端分支,比如bft
# 遇到冲突,解决冲突
git commit
git push
参考链接:
git pull 命令
# git reset --hard会彻底回退到某个版本, 本地的源码也会变为上一个版本的内容
$ git reset --hard 970f341223f34136cd715d667a9d19910a5e2e74
HEAD 现在位于 970f341 update peer3's config to solve read dirty data; add some log to find the reason of config's tx repeating
$ git push -f -u origin bft-test
Username for 'https://github.com': sunriseLe
Password for 'https://[email protected]':
总共 0 (差异 0),复用 0 (差异 0)
To https://github.com/zebra-uestc/madledger.git
+ 519c1ce...970f341 bft-test -> bft-test (forced update)
分支 'bft-test' 设置为跟踪来自 'origin' 的远程分支 'bft-test'。
git merge
命令,将当前分支合并到主分支。方法如下:$ git checkout master
切换到分支 'master'
您的分支与上游分支 'origin/master' 一致。
$ git merge raft
更新 109e1c94..414997fc
Fast-forward
.... # 内容省略
git add fileName
将他进行添加。$ git checkout master
error: 您对下列文件的本地修改将被检出操作覆盖:
consensus/raft/db_test.go
请在切换分支前提交或贮藏您的修改。
终止中
git status
查看,发现确实有些本地文件修改没有提交或取消:$ git status
位于分支 raft
您的分支与上游分支 'origin/raft' 一致。
尚未暂存以备提交的变更:
(使用 "git add <文件>..." 更新要提交的内容)
(使用 "git checkout -- <文件>..." 丢弃工作区的改动)
修改: consensus/raft/db_test.go
git checkout -- fileName
丢弃这些改动,然后在进行分支切换,成功切换到主分支!$ git checkout -- consensus/raft/db_test.go