自用Git笔记
2012-06-15 18:19
190 查看
Git。。。好复杂。。。哈哈,搜索一番后总算能干完我想干的事,做点笔记:
1. clone repo并拉回来
这里其实分两步,之前对git不理解,试了好几次clone了几百MB回来后什么也看不到的情况(囧),因为那个项目master分支是空的~~~
a. git clone http://github.com/someone/someproject.git
等待(似乎网速和项目体积,可以很漫长)
b. 之后可以创建本地分支了(就是刚才拉回来的,是remote镜像,不是下载会本地就成了本地工作目录了,之前就是这里不懂)
git checkout -b <new_branch> origin/<remote_branch>
2. 修改后,git commit
git add -A 或文件名,然后推到remote:
git push
3. 新建一个分支推到远端。(这个命令顺序注意!)
git push origin <new_branch>
推送后,其它分支使用者:
git fetch origin
git checkout --track oirgin/<new_branch> (类似1.b)
4. 更新。
a.本地内容落后
git pull
b. 母档案更新
git remote add <repo_name> http://github.com/someone/somerepo.git
git fetch <repo_name>
git merge <repo_name>/<branch_name> 合并到工作分支
c. 单个commit合并
git cherry-pick <commit_id>
附:密码用户名
每次都要输入用户名密码,很烦
~/.netrc
machine server e.g. github.com
login username
password ******
1) Use
2) Create a patch using
3) Use
4)
git config --global -l
查看已经配置了什么merge工具
如果没有merge.tool和mergetool.kdiff3.path
则输入
git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path "D:/Program Files/KDiff3/kdiff3.exe"
合并错误后的处理:
http://stackoverflow.com/questions/101752/aborting-a-merge-in-git
http://stackoverflow.com/questions/2389361/git-undo-a-merge
1. clone repo并拉回来
这里其实分两步,之前对git不理解,试了好几次clone了几百MB回来后什么也看不到的情况(囧),因为那个项目master分支是空的~~~
a. git clone http://github.com/someone/someproject.git
等待(似乎网速和项目体积,可以很漫长)
b. 之后可以创建本地分支了(就是刚才拉回来的,是remote镜像,不是下载会本地就成了本地工作目录了,之前就是这里不懂)
git checkout -b <new_branch> origin/<remote_branch>
2. 修改后,git commit
git add -A 或文件名,然后推到remote:
git push
3. 新建一个分支推到远端。(这个命令顺序注意!)
git push origin <new_branch>
推送后,其它分支使用者:
git fetch origin
git checkout --track oirgin/<new_branch> (类似1.b)
4. 更新。
a.本地内容落后
git pull
b. 母档案更新
git remote add <repo_name> http://github.com/someone/somerepo.git
git fetch <repo_name>
git merge <repo_name>/<branch_name> 合并到工作分支
c. 单个commit合并
git cherry-pick <commit_id>
附:密码用户名
每次都要输入用户名密码,很烦
~/.netrc
machine server e.g. github.com
login username
password ******
1) Use
git cherry-pickto pluck out the commit. This will create a new commit and preserve the old commit’s metadata.
2) Create a patch using
git format-patchthen bring that in using
git am. This allows you to
--signoffthe commit too! This also makes a new commit.
3) Use
git applywith the patch to put the changes into your working directory so you can edit them further.
4)
git mergethe changes right in, which preserves the original commit (provided there’s no conflicts)
git config --global -l
查看已经配置了什么merge工具
如果没有merge.tool和mergetool.kdiff3.path
则输入
git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path "D:/Program Files/KDiff3/kdiff3.exe"
合并错误后的处理:
http://stackoverflow.com/questions/101752/aborting-a-merge-in-git
http://stackoverflow.com/questions/2389361/git-undo-a-merge