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・sion
  • Initial [ɪˋnɪʃəl] 初始 起始 i・ni・tial
  • Commit [kəˋmɪt] 認可 交付 確認 com・mit

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


shell> git filter-branch --tree-filter 'rm filename' HEAD

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:


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

:books: 參考網站:

- gist

shell> git mv JavaScript javascript

:books: 參考網站:

- git-mv

:books: 參考網站:


:books: 參考網站:


:books: 參考網站:


:books: 參考網站:

WEB_DIR="/var/www/html"
export GIT_DIR="$WEB_DIR/.git"
powered by Gitbook最後更新: 2017-08-25 10:06:20

results matching ""

    No results matching ""