Git clone particular version of remote repository:
Use for that:
git clone [remote_address_here] my_repocd my_repogit reset --hard [ENTER HERE THE COMMIT HASH YOU WANT]
常用操作(完整): 每次编辑完一个文件,都需要重新运行下面三个命令才能上传成功:
$ git add filename #添加更新的文件$ git commit -m "commit description" #更新备注$ git push origin master #推送到远程服务器
查看操作相关命令:
查看当前状态 $ git status 查看远程仓库:$ git remote -v 查看分支 $ git branch 查看历史日志 $ git log
远程仓库操作相关命令
$ git clone git://github.com/someone/some_project.git some_project #将'git://github.com/someone/some_project.git'这个URL地址的远程版本库,完全克隆到本地some_project目录下git clone -b#只克隆某个分支添加远程仓库:$ git remote add [name] [url]git remote add origin git://github.com/someone/another_project.git #增加URL地址为'git: //github.com/someone/another_project.git',名称为origin的远程服务器,以后提交代码的时候只需要使用 origin别名即可删除远程仓库:$ git remote rm [name]修改远程仓库:$ git remote set-url --push [name] [newUrl]拉取远程仓库:$ git pull [remoteName] [localBranchName]推送远程仓库:$ git push [remoteName] [localBranchName]
分支(branch)操作相关命令
查看当前分支:$ git branch -a创建本地分支:$ git branch [name] ----注意新分支创建后不会自动切换为当前分支切换分支:$ git checkout [name]创建新分支并立即切换到新分支:$ git checkout -b [name]创建本地分支,并指定远程分支的对应关系: $ git checkout -b gitcafe-pages remotes/origin/gitcafe-pages删除分支:$ git branch -d [name] ---- -d选项只能删除已经参与了合并的分支,对于未有合并的分支是无法删除的。如果想强制删除一个分支,可以使用-D选项合并分支:$ git merge [name] ----将名称为[name]的分支与当前分支合并
版本还原:
git revert:还原一个版本的修改,必须提供一个具体的Git版本号,例如'git revert bbaf6fb5060b4875b18ff9ff637ce118256d6f20',Git的版本号都是生成的一个哈希值