本文针对初级用户,从最简单的讲起,但是需要读者对Git的基本用法有所了解。同时,本文覆盖了上面5个命令的几乎所有的常用用法,所以对于熟练用户也有参考价值。
本地主机生成一个目录,与远程主机的版本库同名
$ git clone https://github.com/torch/distro.git ~/torch --recursive添加远程仓库地址
$ git remote add yosinski https://github.com/yosinski/caffe.git
$ git fetch --allgit remote show命令加上主机名,可以查看该主机的详细信息。
git remote add命令用于添加远程主机。
git remote rm命令用于删除远程主机。
一旦远程主机的版本库有了更新(Git术语叫做commit),需要将这些更新取回本地,这时就要用到git fetch命令。
$ git fetch <远程主机名>取回远程origin主机的master分支
$ git fetch origin mastergit pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。它的完整格式稍稍有点复杂。
$ git pull <远程主机名> <远程分支名>:<本地分支名>git push命令用于将本地分支的更新,推送到远程主机。它的格式与git pull命令相仿。
$ git push <远程主机名> <本地分支名>:<远程分支名>$ git clone https://github.com/mindcont/caffe.git --recursive
$ git checkout deconv-vis
$ git submodule init
$ git submodule updategit filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "mindcont@users.noreply.github.com" ];
then
GIT_AUTHOR_NAME="mindcont";
GIT_AUTHOR_EMAIL="mindcont@users.noreply.github.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
$ git commit --amend --author="mindcont <mindcont@users.noreply.github.com>" -m "更新博客"