转自: http://blog.sina.com.cn/u/1169817097
总结一下ubuntu下github常用的命令,设置部分跳过,假设repository的名字叫hello-world:
1.创建一个新的repository:
先在github上创建并写好相关名字,描述。
$cd ~/hello-world
$git init
$git add .
$git commit
$git remote add origin git@github.com:WadeLeng/hello-world.git
$git push origin master
2.更新项目(新加了文件):
$cd ~/hello-world
$git add .
$git commit
$git push origin master
3.更新项目(没新加文件,只有删除或者修改文件):
$cd ~/hello-world
$git commit -a
$git push origin master
4.忽略一些文件,比如*.o等:
$cd ~/hello-world
$vim .gitignore
然后就可以git add . 能自动过滤这种文件
5.clone代码到本地:
$git clone
假如本地已经存在了代码,而仓库里有更新,把更改的合并到本地的项目:
$git fetch origin
$git merge origin/master //把更新的内容合并到本地分支
6.撤销
$git reset
7.删除
$git rm
//------------------------------常见错误-----------------------------------
1.$ git remote add