git使用

现在才开始用github托管代码真的是土爆了

http://wuyuans.com/2012/05/github-simple-tutorial/

http://www.linuxidc.com/Linux/2012-06/62168p2.htm

http://www.cnblogs.com/zhangjing230/archive/2012/05/09/2489745.html

http://stackoverflow.com/questions/4181861/src-refspec-master-does-not-match-any-when-pushing-commits-in-git

http://gitref.org/zh/remotes/

在github上登录并创建好一个仓库之后  会有页面出来如何提交的指令

Create a new repository on the command line

touch README.md
git init
git add . //很重要
git add README.md
git commit -m "first commit"
git remote add origin url
git push -u origin master

Push an existing repository from the command line

git remote add origin url
git push -u origin master

还有貌似用sshkeygen工具生成公钥的指令很多啊= =

github上推送分支,在第三个url对应的博文中有提到 后来自己又摸索了一下

# Syntax: git branch <name> <hash> # <hash> in the above is optional 
# if not specified the last commit will be used
# If specified the corresponding commit will be used
git branch testing
# Switch to your new branch
git checkout testing
# Some changes echo "Cool new feature in this branch" > test01
git commit -a -m "new feature" # Switch to the master branch
git checkout master
# Check that the content of test01 is the old one cat test01

进入路径然后git rm XXX

再commit和push 即可完成对某些文件或者整个工程的删除

注意是 git commit -a -m

然后就git push -u origin testing 即可

从github上拷贝分支

git clone -b <branch> <remote_repo>

Example:

git clone -b my-branch [email protected]:user/myproject.git

Alternative (no public key setup needed):

git clone -b my-branch https://[email protected]/username/myproject.git                             
当需要覆盖github上的项目时
git fetch origin; 
git merge origin/master 
git push -u origin master 即可覆盖

你可能感兴趣的:(git使用)