标签:
$ git config user.email "xuym@travelsky.com"
$ git config user.name xuym
$ git config --global credential.helper store
$ git config --global core.autocrlf false
以上分别是邮箱,用户名,密码自动保存,禁止自动换行的设置
$ git clone http://gitlab.cqrd.com/xuym/efront.git
Cloning into ‘efront‘...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ cd efront
$ git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
$ mkdir git
$ cd git
$ mkdir start
$ cd start
$ mkdir git
$ cd git
$ vi git.basic.md
$ cd ../../../
$ pwd
/f/efront
$ ll
total 0
drwxr-xr-x 1 admin 197121 0 五月 10 02:24 git/
$ git status
On branch master
Your branch is up-to-date with ‘origin/master‘.
Untracked files:
(use "git add <file>..." to include in what will be committed)
git/
nothing added to commit but untracked files present (use "git add" to track)
$ git add git
$ git status
On branch master
Your branch is up-to-date with ‘origin/master‘.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: git/start/git/git.basic.md
$ git commit -m "添加文件git/start/git/git.basic.md"
[master 5e9f74e] 添加文件git/start/git/git.basic.md
1 file changed, 1 insertion(+)
create mode 100644 git/start/git/git.basic.md
$ git status
On branch master
Your branch is ahead of ‘origin/master‘ by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
$ git push --set-upstream origin master
Username for ‘http://gitlab.cqrd.com‘: xuym
Password for ‘http://xuym@gitlab.cqrd.com‘:
Counting objects: 6, done.
Writing objects: 100% (6/6), 412 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To http://gitlab.cqrd.com/xuym/efront.git
ba08f19..5e9f74e master -> master
Branch master set up to track remote branch master from origin.
$ git log
commit 5e9f74e814d639ed4b0006b216c9d5c126e6ba37
Author: xuym <xuym@travelsky.com>
Date: Tue May 10 10:48:54 2016 +0800
添加文件git/start/git/git.basic.md
使用页面编辑器在efront库的git目录下增加一个 README.md,里面的内容是: git pull
$ git pull
remote: Counting objects: 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 http://gitlab.cqrd.com/xuym/efront
5e9f74e..fff4ff3 master -> origin/master
Updating 5e9f74e..fff4ff3
Fast-forward
git/start/git/README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 git/start/git/README.md
在本地git目录下修改 README.md,增加的内容是: git diff HEAD
$ git diff HEAD
diff --git a/git/start/git/README.md b/git/start/git/README.md
index bddc158..adbcb9d 100644
--- a/git/start/git/README.md
+++ b/git/start/git/README.md
@@ -1 +1,2 @@
-git pull
\ No newline at end of file
+git pull^M
+git diff HEAD
\ No newline at end of file
$ git status
On branch master
Your branch is up-to-date with ‘origin/master‘.
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: git/start/git/README.md
no changes added to commit (use "git add" and/or "git commit -a")
admin@admin-PC MINGW64 /f/efront (master)
$ git add -A
$ git diff --staged
diff --git a/git/start/git/README.md b/git/start/git/README.md
index bddc158..adbcb9d 100644
--- a/git/start/git/README.md
+++ b/git/start/git/README.md
@@ -1 +1,2 @@
-git pull
\ No newline at end of file
+git pull^M
+git diff HEAD
\ No newline at end of file
$ git reset git/start/git/README.md
Unstaged changes after reset:
M git/start/git/README.md
$ git status
On branch master
Your branch is up-to-date with ‘origin/master‘.
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: git/start/git/README.md
no changes added to commit (use "git add" and/or "git commit -a")
$ git checkout -- git/start/git/README.md
$ git status
On branch master
Your branch is up-to-date with ‘origin/master‘.
nothing to commit, working directory clean
$ git branch dev
$ git checkout dev
Switched to branch ‘dev‘
$ git push --set-upstream origin dev
Total 0 (delta 0), reused 0 (delta 0)
To http://gitlab.cqrd.com/xuym/efront.git
* [new branch] dev -> dev
Branch dev set up to track remote branch dev from origin.
$ git rm ‘*.md‘
rm ‘git/start/git/README.md‘
rm ‘git/start/git/git.basic.md‘
$ git commit -m "删除当前分支上所有文件"
[dev 7bf89ab] 删除当前分支上所有文件
2 files changed, 2 deletions(-)
delete mode 100644 git/start/git/README.md
delete mode 100644 git/start/git/git.basic.md
$ git commit -m "删除当前分支上所有文件"
[dev 7bf89ab] 删除当前分支上所有文件
2 files changed, 2 deletions(-)
delete mode 100644 git/start/git/README.md
delete mode 100644 git/start/git/git.basic.md
$ git checkout master
Switched to branch ‘master‘
Your branch is up-to-date with ‘origin/master‘.
$ git merge dev
Updating fff4ff3..7bf89ab
Fast-forward
git/start/git/README.md | 1 -
git/start/git/git.basic.md | 1 -
2 files changed, 2 deletions(-)
delete mode 100644 git/start/git/README.md
delete mode 100644 git/start/git/git.basic.md
$ git branch -D dev
Deleted branch dev (was 7bf89ab).
git push
$ git reflog
7bf89ab HEAD@{2}: merge dev: Fast-forward
fff4ff3 HEAD@{3}: checkout: moving from dev to master
7bf89ab HEAD@{4}: commit: 删除当前分支上所有文件
fff4ff3 HEAD@{5}: checkout: moving from master to dev
fff4ff3 HEAD@{6}: pull: Fast-forward
5e9f74e HEAD@{7}: commit: 添加文件git/start/git/git.basic.md
ba08f19 HEAD@{8}: commit: 删除文件
7a76ecb HEAD@{9}: commit: js数组
1e5d4e4 HEAD@{10}: commit: javascript数组测验
2926525 HEAD@{11}: pull: Fast-forward
6532730 HEAD@{12}: commit: home
15539c3 HEAD@{15}: commit (initial): my test
$ git reset --hard fff4ff3
HEAD is now at fff4ff3 创建文件README.md
标签:
原文地址:http://blog.csdn.net/xuym123/article/details/51362535