github for Windows使用介绍 这篇文章可以很好带我们入门github,同时还带了一个gitshell,这个工具可以运行github的所有命令,命令才能干更多事情,比如今天我们要完成的一个任务就是如何如何合并Git 代码库中牛人的代码到自己的库。
Windows PowerShell 版权所有(C) 2012 Microsoft Corporation。保留所有权利。
C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]> git branch –a # 查看所有分支 * master remotes/origin/HEAD -> origin/master remotes/origin/master C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]> git remote add coretea m git://github.com/ghorsey/SharpOAuth2.git #加入主项目地址,以便跟上更新 C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]> git fetch coreteam remote: Counting objects: 297, done. #获取主项目更新 remote: Compressing objects: 100% (108/108), done. remote: Total 227 (delta 147), reused 165 (delta 85)Receiving objects: 73% (166 Receiving objects: 74% (168/227), 60.00 KiB | 10 KiB/s Receiving objects: 100% (227/227), 74.24 KiB | 10 KiB/s, done. Resolving deltas: 100% (147/147), completed with 48 local objects. From git://github.com/ghorsey/SharpOAuth2 * [new branch] master -> coreteam/master
#建立主项目作为自己的分支 C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]> git checkout -b coreteam coreteam/master Branch coreteam set up to track remote branch master from coreteam. Switched to a new branch 'coreteam' C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [coreteam]> git branch -a * coreteam master remotes/coreteam/master remotes/origin/HEAD -> origin/master remotes/origin/master
#现在你可以追踪最新的更新并把它们合并到你自己的分支里
# 切换到master分支 C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [coreteam]> git checkout master Switched to branch 'master'
将 coreteam/master 合并到本地的 Master 分支
C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]> git merge coreteam/master Auto-merging README.md Merge made by the 'recursive' strategy. README => README.md | 30 - .../Provider/Mvc/SharpOAuth2.Provider.Mvc.dll | Bin 5120 -> 5120 bytes .../Provider/Mvc/SharpOAuth2.Provider.Mvc.pdb | Bin 11776 -> 11776 bytes ...h2.Provider.ResourceAuthorizationHttpModule.dll | Bin 8704 -> 8704 bytes ...h2.Provider.ResourceAuthorizationHttpModule.pdb | Bin 17920 -> 17920 bytes code/deploy/Provider/SharpOAuth2.Framework.dll | Bin 9216 -> 9216 bytes code/deploy/Provider/SharpOAuth2.Framework.pdb | Bin 11776 -> 11776 bytes .../SharpOAuth2.Provider.Globalization.dll | Bin 13312 -> 13312 bytes .../SharpOAuth2.Provider.Globalization.pdb | Bin 28160 -> 28160 bytes code/deploy/Provider/SharpOAuth2.Provider.dll | Bin 36352 -> 37888 bytes code/deploy/Provider/SharpOAuth2.Provider.pdb | Bin 130560 -> 136704 bytes
code/src/RESTSample/Properties/AssemblyInfo.cs | 4 - code/src/SharpOAuth2.Client/AccessToken.cs | 1 .../SharpOAuth2.Client/Properties/AssemblyInfo.cs | 4 - .../Properties/AssemblyInfo.cs | 4 - code/src/SharpOAuth2.Framework/IToken.cs | 2 - .../Properties/AssemblyInfo.cs | 4 - .../Properties/AssemblyInfo.cs | 4 - .../src/SharpOAuth2.Mvc/Properties/AssemblyInfo.cs | 4 - .../OAuthAuthorizeModule.cs | 7 - .../Properties/AssemblyInfo.cs | 4 - .../Properties/AssemblyInfo.cs | 4 - .../SharpOAuth2.Tests/Properties/AssemblyInfo.cs | 4 - .../AuthorizationProviderTests.cs | 364 ----------- .../Processor/ImplicitFlowProcessorTests.cs | 2 - .../ResourceEndpoint/ResourceProviderTests.cs | 2 - .../Processors/AuthenticationCodeProcessorTests.cs | 4 - .../AuthorizationEndpoint/AuthorizationContext.cs | 2 - .../AuthorizationEndpoint/IAuthorizationContext.cs | 2 - .../Processor/AuthorizationCodeProcessor.cs | 2 - .../Processor/ImplicitFlowProcessor.cs | 2 - code/src/SharpOAuth2/Domain/AccessTokenBase.cs | 93 --- .../SharpOAuth2/Domain/AuthorizationGrantBase.cs | 24 - code/src/SharpOAuth2/Domain/IAuthorizationGrant.cs | 12 .../Fluent/FluentAuthorizationContext.cs | 188 ------ code/src/SharpOAuth2/Fluent/FluentTokenContext.cs | 146 ----- code/src/SharpOAuth2/Framework/ErrorResponse.cs | 22 code/src/SharpOAuth2/Properties/AssemblyInfo.cs | 8 - .../ResourceEndpoint/Processors/BearerProcessor.cs | 2 - .../ResourceEndpoint/ResourceContext.cs | 52 .../ResourceEndpoint/ResourceProvider.cs | 73 -- .../Services/IAuthorizationGrantService.cs | 16 - code/src/SharpOAuth2/Services/ITokenService.cs | 22 - code/src/SharpOAuth2/SharpOAuth2.Provider.csproj | 1 .../Processor/AuthenticationCodeProcessor.cs | 44 -- .../AuthorizationGrant.cs | 3 - .../Properties/AssemblyInfo.cs | 4 - .../Service/AuthorizationGrantService.cs | 96 --- .../Service/ClientService.cs | 108 --- .../Service/TokenService.cs | 178 ----- code/src/clean.pyc | Bin 1351 -> 1360 bytes 51 files changed, 838 insertions( ), 710 deletions(-) rename README => README.md (73%) create mode 100644 code/src/SharpOAuth2/Domain/IAuthorizationGrant.cs
# 将主分支修改推送到服务器 C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]> git push origin master
Counting objects: 308, done. Delta compression using up to 8 threads. Compressing objects: 100% (52/52), done. Writing objects: 100% (233/233), 75.05 KiB, done. Total 233 (delta 151), reused 226 (delta 147) To https://github.com/geffzhang/SharpOAuth2.git f3d8955..124c360 master -> master C:UsersgeffzhangDocumentsGitHubSharpOAuth2 [master]>
下面是一些比较有用的命令的介绍:
# 创建一个版本库
git init
# 每次修改好了后,可以先将修改存入stage(快照/索引)中
git add <modified files>
# 修改了大量文件则使用下面这个命令批量存入
git add .
# 使用commit将快照/索引中的内容提交到版本库中
git commit -m"msg"
# 也可以将git add与git commit用一个指令完成
git commit -a-m"msg"
# 将本地的git档案与github(远程)上的同步
git push
# 将github(远程)的git档案与本地的同步(即更新本地端的repo)
git pull
# 例如,pull指令其实包含了fetch(將变更复制回來)以及merge(合并)操作
git pull git://github.com/tom/test.git
# 另外版本控制系統的branch功能也很有意思,若同时修改bug,又要加入新功能,可以fork出一个branch:一个专门修bug,一个专门加入新功能,等到稳定后再merge合并
git branch bug_fix # 建立branch,名为bug_fix
git checkout bug_fix # 切换到bug_fix
git checkout master #切换到主要的repo
git merge bug_fix #把bug_fix这个branch和现在的branch合并
# 若有remote的branch,想要查看并checkout
git branch -r# 查看远程branch
git checkout -b bug_fix_local bug_fix_remote #把本地端切换为远程的bug_fix_remote branch并命名为bug_fix_local
# 还有其它可以查看repo状态的工具
git log #可以查看每次commit的改变
git diff#可以查看最近一次改变的內容,加上参数可以看其它的改变并互相比较
git show #可以看某次的变更
# 若想知道目前工作树的状态,可以輸入
git status
配置http代理 git config --global http.proxy http://web-proxy.xxxxx.com:8080
git 删除错误提交的commit
方法:
git reset --hard <commit_id>
git push origin HEAD --force
其他:
根据–soft –mixed –hard,会对working tree和index和HEAD进行重置:
git reset –mixed:此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息
git reset –soft:回退到某个版本,只回退了commit的信息,不会恢复到index file一级。如果还要提交,直接commit即可
git reset –hard:彻底回退到某个版本,本地的源码也会变为上一个版本的内容
HEAD 最近一个提交
HEAD^ 上一次
<commit_id> 每次commit的SHA1值. 可以用git log 看到,也可以在页面上commit标签页里找到.
git/github初级运用自如
git/github学习笔记
总结自己的Git常用命令
学一点Git--20分钟git快速上手
如何在github上fork一个项目来贡献代码以及同步原作者的修改
Git远程操作详解