git經常使用操做

SSH安全配置

  • 公鑰私鑰
wenlin@wenlin:~$ ls .ssh
id_rsa  id_rsa.pub  known_hosts

若是不存在,生成:github

ssh-keygen -t rsa -C "youremail@example.com"

# 使密鑰當即生效
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

將公鑰id_rsa.pub配置到github。安全

Git配置

git config user.name
git config user.email
Add git config --global key value
Get git config -l
git config --system list
git config --global list
git config --local list

經常使用操做

git clone git@github.com:michaelliao/gitskills.git

# 遠程庫
git remote add origin git@github.com:michaelliao/learngit.git
git remote show
# 查看遠程庫信息
git remote -v

# diff操做:
git status
git diff
git add
git checkout

# 代碼pull/push/rebase/reset
git pull origin master

git branch -b new-branch
# 刪除master以外的分支
git branch | grep -v "master" | xargs git branch -D
git checkout master
git rebase master
git log
git reset --soft commit_id
git reset --soft HEAD^
git reset --hard commit_id

# 切換到臨時分支commit
git checkout -q `git rev-parse HEAD`
git reset --soft master
git commit

# commit信息格式
Add waiting dialog for ftp file list.

1. Add waiting dialog for ftp file list.
2. Add waiting dialog for ftp file tree.

TFS-WX: 10000

# git show/push
git show
git push gerrit HEAD:refs/for/master
相關文章
相關標籤/搜索