Settings:
git config --global user.name "username"git config --global user.email "email"
*to check --> git config --list
*config file : ~/.gitconfig
initial:
ssh-keygen -C "username@email.com" -t rsa* Generate files to .ssh/, public key paste to Github setting
Initialize A Repo:
mkdircd
touch README
git add README
git commit -m 'first commit'
Clone A Repo:
git clone [url] [Target Directory]Staging/Tracking:
git add
Status:
git status
git diff --> changed but not staged
git diff --cache --> staged
git status -s (-s --> short)
(
? ? : untracked
A : new
M : Modified but not added
M : Modified and added
MM : Modified again after added
D : deleted project file
)
Commit:
git commit -m "[comment]"
git commit -a --> stage everyfile tracked
git commit --amend --> amend a previeous commmit
Ignore files:
.gitignore
Remove File:
git rm
git rm --cached [file] --> remove from staging area
Move File:
git mv [file_from] [file_to]
Commit History:
git log
git log -p --> show diff
git log -2 --> last 2 commit
git log --stat --> brief
git log --pretty --> foramtting
git log --graph --> branch & merge history
Unmodify:
git checkout -- [file]
Remote:
A remote-->
repo stored in other computer
origin --> default remote name
git
remote -v --> show remote URLs(for the repo)
git
remote add [remote-name] [repo URL]
git fetch [remote-name] --> fetch from remote
git pull [remote-name] --> fetch and merge from remote
git push [remote-name]
[local-branch-name] --> push to remote
git remote show
[remote-name]
git
remote rename [old-name] [new-name]
git remote rm [remote-name]
git tag:
git tag --> show tag in cur.
repo
git tag -a [tag] -m [comment] -->
annot. tag
git tag -s --> signed tag
git alias:
git config --global alias.[alias] '[command]'
Creating new repo for sync w/ github:
*create repo at
github first
*Push to the remote repo
e.g.:
git remote add [remote-name] https://github.com/[username]/[githubrepo] ([remote-name] is user defined)
git commit -m "first commit"
git push -u [remote-name] master
沒有留言:
張貼留言