git提交文件以及撤銷

zhaojunyandeMBP:testgit zhaojunyan$ git clone https://github.com/JunyanZhao/etcdStudy.git
Cloning into 'etcdStudy'...
warning: You appear to have cloned an empty repository.
zhaojunyandeMBP:testgit zhaojunyan$ ls
etcdStudy
zhaojunyandeMBP:testgit zhaojunyan$ cd etcdStudy/
zhaojunyandeMBP:etcdStudy zhaojunyan$ ls
zhaojunyandeMBP:etcdStudy zhaojunyan$ touch main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ vim main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    main.go

nothing added to commit but untracked files present (use "git add" to track)
zhaojunyandeMBP:etcdStudy zhaojunyan$ git add main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ git commit -m "add main"
[master (root-commit) 3ef2927] add main
 1 file changed, 4 insertions(+)
 create mode 100644 main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ git push origin master 
Counting objects: 3, done.
Writing objects: 100% (3/3), 234 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/JunyanZhao/etcdStudy.git
 * [new branch]      master -> master
zhaojunyandeMBP:etcdStudy zhaojunyan$ vim main.go 
zhaojunyandeMBP:etcdStudy zhaojunyan$ 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:   main.go

no changes added to commit (use "git add" and/or "git commit -a")
zhaojunyandeMBP:etcdStudy zhaojunyan$ git diff main.go
diff --git a/main.go b/main.go
index 1661cbb..0410e87 100644
--- a/main.go
+++ b/main.go
@@ -1,4 +1,5 @@
 package main

 func main(){
+               fmt.Println()
 }
zhaojunyandeMBP:etcdStudy zhaojunyan$ git checkout main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
zhaojunyandeMBP:etcdStudy zhaojunyan$ vim main.go 
zhaojunyandeMBP:etcdStudy zhaojunyan$ 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:   main.go

no changes added to commit (use "git add" and/or "git commit -a")
zhaojunyandeMBP:etcdStudy zhaojunyan$ git add main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ git reset HEAD main.go
Unstaged changes after reset:
M   main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ 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:   main.go

no changes added to commit (use "git add" and/or "git commit -a")
zhaojunyandeMBP:etcdStudy zhaojunyan$ git checkout main.go
zhaojunyandeMBP:etcdStudy zhaojunyan$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
zhaojunyandeMBP:etcdStudy zhaojunyan$ 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章