Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (master)
$ git remote add origin https://gitlab.com/wtdig/wtdigstudy.git
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (master)
$ git branch
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (master)
$ git fetch origin wtbranch
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From https://gitlab.com/wtdig/wtdigstudy
* branch wtbranch -> FETCH_HEAD
* [new branch] wtbranch -> origin/wtbranch
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (master)
$ git checkout -b wtbranch origin/wtbranch
Branch wtbranch set up to track remote branch wtbranch from origin.
Switched to a new branch 'wtbranch'
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git branch
* wtbranch
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git branch --all
* wtbranch
remotes/origin/wtbranch
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git pull origin wtbranch
From https://gitlab.com/wtdig/wtdigstudy
* branch wtbranch -> FETCH_HEAD
Already up-to-date.
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git status
On branch wtbranch
Your branch is up-to-date with 'origin/wtbranch'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git add .
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git commit -m "111"
[wtbranch 6c8e8be] 111
1 file changed, 3 insertions(+)
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
$ git push
Username for 'https://gitlab.com': wtdig
Counting objects: 3, done.
Writing objects: 100% (3/3), 274 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for wtbranch, visit:
remote: https://gitlab.com/wtdig/wtdigstudy/merge_requests/new?merge_request%5 Bsource_branch%5D=wtbranch
remote:
To https://gitlab.com/wtdig/wtdigstudy.git
6fae6d5..6c8e8be wtbranch -> wtbranch
Administrator@PC-20160818BBXC MINGW64 ~/Desktop/test (wtbranch)
例如:将gitLab 上的dev分支拉取到本地
1》与远程仓库建立连接:git remote add origin XXXXX.git
2》使用git branch 查看本地是否具有dev分支
3》如果没有 git fetch origin dev
4》git checkout -b dev origin/dev在本地创建分支dev并切换到该分支
5》git pull origin dev就可以把gitLab上dev分支上的内容都拉取到本地了
1、clone项目
git clone https://gitlab.com/wtdig/wtdigstudy.git
2、创建一个本地分支和远程仓库一样
git checkout -b origin wtbranch
3、同步远程的wtbranch代码到本地的分支
git pull origin wtbranch
4、将本地修改的代码提交上去
git add .
git commit -m "test"
5、将修改推送到远程仓库
git push origin wtbranch
修改git log的内容:比如姓名和邮箱
git filter-branch -f --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "老的邮箱" ];
then
GIT_AUTHOR_NAME="登录名";
GIT_AUTHOR_EMAIL="新的邮箱";
git commit-tree "$@";
else
git commit-tree "$@";
fi' -- 你需要改变的版本号^..HEAD HEAD
示例:
git filter-branch -f --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ];
then
GIT_AUTHOR_NAME="wb-wt261136";
GIT_AUTHOR_EMAIL="[email protected]";
git commit-tree "$@";
else
git commit-tree "$@";
fi' -- 0e9947413ca04b5090931bcfacc22c8caf0f2f8f^..HEAD HEAD