Git命令操作GitHub和Visual Studio Online

来源:互联网 发布:wap论坛源码 编辑:程序博客网 时间:2024/05/01 20:24

http://www.open-open.com/lib/view/open1414396787325.html

https://www.visualstudio.com/en-us/docs/git/gitquickstart#clone

http://www.yiibai.com/git/git_push.html

从远程获取最新版本到本地:

--git fetch origin master

git pull origin master

把远程下载下来的文件合并到本地仓库

git merge origin/master

@echo offD:cd MMFeedcd MMFeedHealthyDatacachecd GitResporsitorycd VideoIGDataREM git clone https://msasg.visualstudio.com/DefaultCollection/Bing_UX/_git/VideoIGData //克隆(第一次获取最新)git pull https://msasg.visualstudio.com/DefaultCollection/Bing_UX/_git/VideoIGData Manifest_BWInt_Test //获取分支<pre name="code" class="csharp">Manifest_BWInt_Test上的最新版本@pause

忽略本地某个文件的未被提交的修改:(即撤销修改),有三种方法:

1. 回退到上一个版本:(见下面:将本地文件回退到之前的版本:

2.手动修改文件内容知道与上一个版本内容相同,在add到暂存区,最后commit到Git

3.D:\GitRepository\VideoIGData\Feed\manifest_BWInt>git checkout 120sports.com_inc_150724/manifest.xml

提交本地某个文件到Git:

D:\GitRepository\VideoIGData\Feed\manifest_BWInt>git add 120sports.com_inc_150724/manifest.xml //先添加到暂存区<pre name="code" class="csharp">D:\GitRepository\VideoIGData\Feed\manifest_BWInt>git commit -m '提交的comments' //将该文件提交到Git仓储VideoIGData

查看当前所在分支:

git status

查看本地文件和Git上文件内容的区别:

<pre name="code" class="csharp">D:\GitRepository\VideoIGData\Feed\manifest_BWInt>git diff 120sports.com_inc_150724/manifest.xml

查看历史记录:从最近到最远的日志

<pre name="code" class="csharp">D:\GitRepository\VideoIGData\Feed\manifest_BWInt>git log

本地文件回退到之前的版本:

<pre name="code" class="csharp">D:\GitRepository\VideoIGData>git reset --hard HEAD^ //回退到上一个版本<pre name="code" class="csharp"><pre name="code" class="csharp">D:\GitRepository\VideoIGData>git reset --hard HEAD~100 //回退到前一百个版本

查看版本号:

git reflog

删除某个文件:

<pre name="code" class="csharp">D:\GitRepository\VideoIGData\Feed\manifest_BWInt>git rm 120sports.com_inc_150724/manifest.xml然后再commit,如果还没commit,则可以恢复被删的文件:git checkout --120sports.com_inc_150724/manifest.xml

创建分支并切换

git checkout -b newBranch //创建了newBranch分支,并切换到了该分支git branch newBranch // 指创建分支newBranchgit checkout newBranch //切换分支

查看当前的分支:

git branch //列出了所有分支, 并标亮当前分支



0 0