





shell> mkdir helloworld
shell> git init
shell> edit hello.c
shell> git add hello.c
shell> git status
shell> git commit -m "initial commit" --author "A U Thor <[email protected]>"
shell> git log
shell> git commit --amend -m "Initial commit" --author "A U Thor <[email protected]>"
shell> git log
shell> git add .
shell> git commit -m "initial revision"
Revision[rɪˋvɪʒən]修訂re・vi・sionInitial[ɪˋnɪʃəl]初始起始i・ni・tialCommit[kəˋmɪt]認可交付確認com・mit
參考網站:
shell> git config -l
shell> git config --system -l
shell> git config --global -l
shell> git config --local -l
shell> git config --system user.name "Your Name"
shell> git config --system user.email [email protected]
shell> git config --global user.name "Your Name"
shell> git config --global user.email [email protected]
shell> git config --global color.ui true
shell> git config --global push.default simple
shell> git config --local user.name "Your Name"
shell> git config --local user.email [email protected]
shell> git config --local color.ui true
shell> git config --unset user.name
shell> git config --global --edit
shell> git commit --amend --reset-author
shell> git config --global user.name "Your Name"
shell> git config --global user.email [email protected]
shell> git config --global color.ui true
參考網站:
shell> mkdir helloworld
shell> git init
shell> edit hello.c
shell> edit hello.h
shell> git add .
shell> git status
shell> git rm --cached hello.h
shell> git status
參考網站:
shell> git show --pretty="" --name-only de05672
shell> git ls-tree --name-only HEAD
shell> mkdir helloworld
shell> git init
shell> edit hello.c
shell> edit hello.h
shell> git add .
shell> git commit -m "initial revision"
shell> git log --pretty=oneline --abbrev-commit
810801f initial revision
shell> git ls-tree --name-only HEAD
shell> git ls-tree --name-only 810801f
shell> git rm --cached hello.h
shell> git commit --amend -C HEAD
shell> git ls-tree --name-only HEAD
參考網站:
shell> git filter-branch --tree-filter 'rm filename' HEAD
參考網站:
shell> edit hello.c hello.h
shell> git add hello.c
shell> git status
shell> touch .gitignore
shell> edit .gitignore
shell> git commit -m "My changes"
shell> git log
.gitignore
.gitignore
# This is a comment
# Ignore the file test.md
test.md
# Ignore everything in the directory "bin"
bin/*
*.h
參考網站:
shell> rm -f hello.c
shell> git checkout hello.c
shell> git checkout -- '*.c'
shell> git checkout -- *
shell> git checkout -- hello.c
shell> edit hello.c
shell> git add hello.c
shell> git commit -m "initial revision"
shell> edit hello.c
shell> git add hello.c
shell> git commit -m "My changes"
shell> edit hello.c
shell> git log --pretty=oneline
53ae079ba38047b2d8709c42e1ef88705e497936 My changes
0a717d53efd86893b1bf47c7c7a43135ea3279d6 initial revision
shell> git checkout 0a71 hello.c
參考網站:
shell> git add .
warning: CRLF will be replaced by LF in myfile.txt.
The file will have its original line endings in your working directory.
shell> git config --global core.autocrlf
shell> git config --global core.autocrlf input
shell> git config --global core.autocrlf true
shell> git config --global core.autocrlf false
shell> git config --global core.eol
shell> echo "* text=auto" >.gitattributes
.gitattributes
* text=auto
*.txt text
*.vcproj text eol=crlf
*.sh text eol=lf
*.jpg -text
*.jpg -text -diff
*.md text eol=lf
*.markdown text eol=lf
*.c filter=indent
manual.pdf -text
weirdchars.txt text
參考網站:
shell> edit hello.c
shell> git add hello.c
shell> git rm hello.c
shell> git rm --cached hello.c
shell> git reset HEAD hello.c
shell> git reset HEAD^
shell> git reset HEAD^ --hard
參考網站:
shell> bfg --no-blob-protection --delete-files YOUR-FILE-WITH-SENSITIVE-DATA
shell> bfg --no-blob-protection --delete-files id_{dsa,rsa} my-repo.git
shell> git reflog expire --expire=now --all && git gc --prune=now --aggressive
shell> git clone --bare https://github.com/you/HelloWorld.git HelloWorld.git
shell> bfg --no-blob-protection --delete-files id_{dsa,rsa} HelloWorld.git
參考網站:
shell> git log --pretty=oneline
shell> git log --pretty=oneline --abbrev-commit
shell> git remote add origin YOUR_GIT_CLONE_URL_HERE
shell> git remote add origin https://github.com/you/HelloWorld.git
參考網站:
shell> git add -A
shell> git add .
shell> git add -u
shell> mkdir helloworld
shell> git init
shell> git add .
shell> git commit -m "initial commit"
shell> git remote add azure [URL for remote repository]
shell> git push azure master
shell> mkdir HelloWorld
shell> cd HelloWorld
shell> git init
shell> echo HelloWorld > testfile.txt
shell> git status
shell> git add . -n
shell> git add .
shell> git status
shell> git commit -a
shell> git log
shell> git commit -a -m "Initial commit"
shell> git commit -m "Demo"
shell> git commit -m "My changes"
shell> git commit -am "disable node_modules cache" --allow-empty
shell> git push heroku master
shell> git add package.json
shell> git commit -m "Added package.json"
shell> git diff HEAD testfile.txt
shell> git show
shell> git diff 0fcd2baef5b6741412db6eb3bd2c2b559a02b64f fd7f63f055f2e6ecc23be1a9a3b33a438ae68ead
shell> git remote add origin https://[email protected]:443/your-azure-website.git
shell> git push
shell> git show --pretty="" --name-only HEAD
shell> git show --pretty="" --name-only HEAD~1
shell> git show --pretty="" --name-only HEAD~2
shell> git show HEAD:testfile.txt
shell> git show HEAD:testfile.txt> testfile.txt
Aborting commit due to empty commit message.
Aborting正在中止Empty[ˋɛmptɪ]空的空空白emp・ty
shell> git clone --bare HelloWorld HelloWorld.git
shell> scp -r HelloWorld.git [email protected]:/opt/git
shell> git clone [email protected]:/opt/git/HelloWorld.git
shell> git remote -v
shell> git push origin master
shell> git remote set-url origin [email protected]:/opt/git/HelloWorld.git
shell> git remote show origin
shell> git remote add azure https://[email protected]:443/your-azure-website.git
shell> git push azure master
shell> mkdir HelloWorld.git
shell> cd HelloWorld.git
shell> git init --bare
shell> mkdir HelloWorld
shell> cd HelloWorld
shell> git init
shell> echo HelloWorld > testfile.txt
shell> git commit -a -m "Initial commit"
shell> git commit -a -m "My changes"
shell> git remote add origin /opt/git/HelloWorld.git
shell> git push origin master
shell> git clone /opt/git/HelloWorld.git
shell> git clone [email protected]:/opt/git/HelloWorld.git
shell> git remote set-url origin [email protected]:/opt/git/HelloWorld.git
shell> git remote -v
shell> git commit -a -m "My changes"
shell> git push origin master
shell> git pull origin master
shell> git pull --progress
shell> git branch
shell> git branch -vv
shell> git branch --remotes
shell> git push origin --delete Branch_df65c30a8bb632955646b90f778c0cb5a7c5b28f
參考網站:
- gist
shell> git mv JavaScript javascript
參考網站:
- git-mv
參考網站:
參考網站:
- git-remote
- Customizing-Git-Git-Configuration
- Git for Windows
- 程式開發者的社群網路新世界
- 從集中版本控制到分散式版本控制
- 持續整合下的版本控管做法
- 語意明確的版本變更
- 軟體開發過程中不能缺少的系統
- https://www.ibm.com/developerworks/library/d-learn-workings-git/
- https://www.ibm.com/developerworks/library/wa-git/
- https://developer.ibm.com/opentech/2016/02/01/git-with-it/
參考網站:
- https://git-scm.com/book/be/v2/Git-Tools-Credential-Storage
- caching-your-github-password-in-git
- connecting-to-github-with-ssh
參考網站:
WEB_DIR="/var/www/html"
export GIT_DIR="$WEB_DIR/.git"