安装: sudo apt-get install git-core
第一次使用配置:
git config --global user.name "bob"
git config --global user.email "83800572@qq.com"
初始化:git init
添加: git add .
提交:git commmit -m "first"
忽略文件:.gitigonore
查看修改情况:git status git diff
撤销未提交的修改:git checkout
取消添加:git reset
查看提交记录:git log
创建分支:git branch versionLite
切换分支:git checkout versionLite
合并操作:git checkout master
git merge versionLite
删除分支:git branch -D versionLite
下载github代码到本地:git clone https://github.com...
本地同步到github:git push origin master
github同步到本地:git fetch origin master
git diff origin/master git merge origin/master
git pull origin mastwr
本地代码仓库关联到github(MAC):
1.进入用户名/.shh目录下:ssh-Keygen -t rsa -C “github的邮箱地址” 输入完之后一直回车直到成功
2.复制.ssh/id_rsa.pub里面的内容:pbcopy < ~/.ssh/id_rsa.pub
3.登陆github 点击右上角头像,弹出列表选择“Settings”,然后选择“SSH and GPG keys”。添加 SSH Keys,点击===>New Ssh key===>Title(可以写上自己的邮箱)===>key(粘贴在终端复制的SSH Keys)===>点击Add SSH key添加。
4.ssh -T git@github.com, 输入 yes 回车
5.进入github项目,获取地址:git remote add origin https://github.com/bobgreatman/baidumap.git
6.git clone https://github.com/bobgreatman/baidumap.git
7.git add .
8.git commit -m "to github"
9.git push origin master