How to configure and use Git with visual studio 2012 and TFS

/*

Author: Jiangong SUN 

*/


"GIT: is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency." 

 - from git-scm.com


Here I want to introduce how to configure and use Git with visual studio 2012 and TFS.


To use git in your visual studio environnement, you need to meet prerequisites requirement. You need to install the following tools in your windows system.
- Visual Studio 2012 with update 2
- Git for Windows
- Visual Studio Tools for Git extension


Once you have installed these tools, you need to configure GIT as visual studio source control.
Tools -> Options -> Source Control -> Microsoft Git Provider


You can create team project + git in TFS server.

Then choose Scrum  as process template and Git as version control.



Open git command line on your windows system, go to your git server repository.

cd c:\GITServerRepository
update your projet from TFS server.
git clone https://xxx.com/DefaultCollection/_git/test
create project in visual studio with source control option


now you need to do to initialize and update your project using following commands:

->git init
->git add .
->git commit -m 'init message'


->git push origin master


->git pull


GIT common commands:

->git init: (re)init git repository for a project
->git clone server-git-directory: get a project copy from server
->git add .: add all files of current directory to new project


->git rm file-name: remove file name from project
->git help command-name: get help for specific command
->git status: get status of current branch


->git status -s: short version of status
->git branch: list all the project branches


->git branch branch-name: create a branch with name "branch-name"


->git branch -v: get last commit on each branch
->git branch -d branch-name: delete branch


->get checkout master: switch to master branch

->git checkout -b branch-name: create and switch ot branch
->git merge branch-name: merge a branch to master(trunk)


->git commit -am 'message': commit all changes with message


->git push origin master: the first init push to TFS server
->git push: push changes to TFS server


->git pull: get latest modifcations from TFS server
->git log: get log for current branch


->git tag -a v1.0: create tag named "v1.0"
->git tag -l: list all tags
->git show v1.0: show tag information
->git diff: show difference between last commits
->git diff --stat | --shortstat: display statistiques between last commits
->git diff --cached: show difference for staged modifications


Common linux commands:

->cd directory: go to directory
->touch file-name: create file
->vi file-name: edit file
->vim file-name: edit file
("i" for input text, "ESC + wq" for save input and exit the editor)
->cat file-name: read file
->rm -i file-name: remove file with confirmation
->rmdir directory-name: remove empty directory
->rm -r directory-name: remove directory and all files within
->cp -p file-name1 file-name2: copy file1 to file2 with the same user, timestamp information.
->ls -l -a -s: list all files with right(-l), with hidden files(-a), with file size(-s)
->mkdir directory-name: create empty directory
->mv old-directory-name new-directory-name: change name for directory
->clear: clear screen


Enjoy coding!

reference:
http://gitref.org
http://git-scm.com/book/en/Git-Basics-Tagging
http://www.debianhelp.co.uk/commands.htm


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值