Peter.Chen
2018/01/24
https://www.git-tower.com/learn/git/ebook/en/desktop-gui/appendix/from-subversion-to-git
https://git-scm.com/book/en/v2/Getting-Started-Git-Basics
下git init後,目標資料夾下會多一個.git的隱藏資料夾,有此資料夾代表此目錄就是git directory
PS D:\Code\Personal\GitDemo> git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
hellogit.txt
nothing added to commit but untracked files present (use "git add" to track)
PS D:\Code\Personal\GitDemo>
PS D:\Code\Personal\GitDemo> git add .\hellogit.txt
PS D:\Code\Personal\GitDemo> git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: hellogit.txt
git add將此檔案變更設定為此次提交
PS D:\Code\Personal\GitDemo> git commit -m 'Initial Project'
[master (root-commit) 4d14395] Initial Project
1 file changed, 1 insertion(+)
create mode 100644 hellogit.txt
PS D:\Code\Personal\GitDemo>
在staging area中的檔案資訊被提交到repo上
PS D:\Code\Personal\GitDemo> git log
commit 4d1439564da9eb61660e9061586fe4702f179472
Author: peter_hp_chen <peter_hp_chen@gmail.com>
Date: Wed Jan 24 00:10:07 2018 +0800
Initial Project
git log查找提交紀錄
1. 建立資料夾
2. git init
3. git add
4. git status
5. git commit
PS D:\Code\Personal\GitDemo> git branch develop
PS D:\Code\Personal\GitDemo> git branch -v
develop 4d14395 Initial Project
* master 4d14395 Initial Project
git checkout {branch name}
將分支檔案拉回工作目錄上
PS D:\Code\Personal\GitDemo> git checkout develop
Switched to branch 'develop'
PS D:\Code\Personal\GitDemo> git branch -v
* develop 4d14395 Initial Project
master 4d14395 Initial Project
git remote add origin https://github.com/peterhpchen/GItDemo.git
PS D:\Code\Personal\GitDemo> git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 236 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/peterhpchen/GItDemo.git
* [new branch] master -> master
git push {remote repo name} {branch name}
PS D:\Code\Personal\GitDemo> git clone https://github.com/peterhpchen/GItDemo.git
Cloning into 'GItDemo'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
PS D:\Code\Personal\GitDemo> git pull origin master
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/peterhpchen/GItDemo
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
PS D:\Code\Personal\GitDemo> git status
On branch 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: hellogit.txt
no changes added to commit (use "git add" and/or "git commit -a")
PS D:\Code\Personal\GitDemo> git add .\hellogit.txt
PS D:\Code\Personal\GitDemo> git commit -m 'Local modified txt'
[master a4a0340] Local modified txt
1 file changed, 1 insertion(+), 1 deletion(-)
PS D:\Code\Personal\GitDemo> git pull origin master
From https://github.com/peterhpchen/GItDemo
* branch master -> FETCH_HEAD
Auto-merging hellogit.txt
CONFLICT (content): Merge conflict in hellogit.txt
Automatic merge failed; fix conflicts and then commit the result.
PS D:\Code\Personal\GitDemo> git merge reset
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
修改為正確的內容後再做次commit
PS D:\Code\Personal\GitDemo> git add .\hellogit.txt
PS D:\Code\Personal\GitDemo> git commit -m 'Modified is correct'
[master 0d17348] Modified is correct
PS D:\Code\Personal\GitDemo> git push origin master
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 459 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/peterhpchen/GItDemo.git
c60c781..0d17348 master -> master