Git 常用指令(Git Tips)

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

此篇記錄筆者常用的Git指令。

Configuration相關
git config --global user.name "username"
git config --global user.email "username@mail.domain.address"
git config --global core.editor vim

# Line Ending
git config --global core.autocrlf input
git config --global core.safecrlf true

# Color Highlighting
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
or
git config --global color.ui auto

# Set bare repository
git config --bool core.bare true
git config --bool core.bare false

# Sharing repository with group member
git config core.sharedRepository group
git repo-config core.sharedRepository group

# Proxy Setting
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --global https.proxy http://proxyuser:proxypwd@proxy.server.com:8080

Backup 相關
Backup a git repository (The quick and easy way)
git bundle create bundleName/Path/To branch_name
git bundle create /tmp/foo master
git bundle create /tmp/foo-all --all (for all branch)
git bundle list-heads /tmp/foo
git bundle list-heads /tmp/foo-all
git bundle verify bundle_name

Restoring a git repository
git clone bundle_name repo_Destination_Path branch_name
git clone bundle_name repo_Destination_Path -b master (with source code)
git clone --bare bundle_name repo_Destination_Path -b master (for bare repository no source code)

Restore a file from a specific commit
git checkout [commit_id] file/to/restore

Untracked a file
git rm --cached filePath

Delete commit
git reset --soft
git reset --hard
=========================================================================
View the change history of an individual file
gitk [filename]
git log --[filename]
git rm -r --cached <your directory>

Checking status
git status -u

沒有留言: