Github and Git memo 备忘录

可以查看http://gitref.org/来找到更全的命令信息

本地操作

1  安装git bash 

http://help.github.com/win-set-up-git/

你的ssh key:cd  ~/.ssh/id_rsa.pd

2 进入你的项目目录Hellogit

    git init :git初始化,创建一个repo(仓库)

3 假设我们的文件夹里:

$ cd Hellogit
$ ls
README   hello.rb

    默认这个就是我们的master分支

4 添加一个文件到你的repo

$git add hello.txt

或者添加所有文件

$git add .

5 提交修改

$ git commit -m 'add a file'
或多个文件提交

$ git commit -a -m 'add a file'
6 查看几次commit的区别

$git diff

7 创建一个branch,(有什么用?可以让你安心的再里面修改,如果写的顺利,可以合并到master里,如果那边出错了,可以回到master)

查看branch列表

$git branch
新建并且切换到该branch

$git checkout -b branch
新建一个branch

$git branch branchname
切换到该branch

$git checkout branchname
8 合并branch (新的feature写完了,可以合并到master里面去了)

$git merge branchname
9 删除branch

$git branch -d name


远程操作,和Github 与 Google code


上传自己的repo

1 建立个远程站点

添加站点,schacon是用户名,hw是repo名

git remote add github [email protected]:schacon/hw.git

列出你现在的远程站点

$git remote -v


2 上传自己的repo , branchname 指定上传到那个分支去

$git push github branchname


3 删除远程的分支

$git push github --delete branchname


4 下载repo 从远程站点

$git clone git://github.com/schacon/simplegit.git


关于Google code project

当你上传自己的repo时,会提示要你输入密码和用户名,为了方便,我们可以在home目录(windows中 cd ~)建立一个.netrc文件(windows中为 _netrc)

$vi _netrc
添加:machine code.google.com login [email protected] password your_pwd

这样,下次就直接可以上传了。









你可能感兴趣的:(windows,git,Google,File,merge,branch)