Git 用户配置
1.set user.email and name
git config --global user.email "your email"
git config --global user.name "your name"
2.create SSH
ssh-keygen -t rsa -C "your email"
3.save local key to github setting
copy key in ~/.ssh/id_rsa.pub
to github setting SSH keys
4.store your account and psw
git config --global credential.helper store
git pull
保留账户和密码
# run
git config --global credential.helper store
# and then
git pull
# and then
# input your name and pwd
Git 设置代理
git config --global http.proxy 127.0.0.1:****
git config --global https.proxy 127.0.0.1:****
and then
git config --list
to show your config
Git初始化本地已有项目
1.初始化仓库
git init
2.remote
git remote add origin <仓库地址>
3.从远程分支拉取master分支并与本地master分支合并
git pull origin master:master
4.提交本地分支到远程分支
git push -u origin master
5.将现有项目添加并提交上传
git add -A
git commit -m 'something'
git push --set-upstream origin master
其他
1.撤销commit
git reset --soft HEAD~n # 倒数第n个
2.撤销已添加的文件
git rm --cache path_to_file
3.update gitignore
git rm -r --cached . && git add . && git commit -am "Remove ignored files"
4.track remote branch
# create a new local branch to track remote branch
git checkout --track origin/dist
git branch -u origin/release release
5.tracking info
git branch -vv # doubly verbose!