I have 10+ years of experience with TFS and now I have an project which uses Git as source control system. I decided to wrote some notes which can help another experienced TFS users to start with Git. Key differences:
- Git is decentralized, while TFS has one central repository on TFS server. As for the Git there is one remote repository and then local repositories on developer machines. Due to this, the sync of commits between the repositories is needed.
- Git has commits, while in TFS we have changesets.
- Git branches are lightweight, while TFS branches allocates much more disk space.
- TFS get latest version = Git fetch + pull
- TFS check-in = Git commit + push
Next I will show some of the basic commands needed for the daily work. We start with cloning remote reposity using command:
git clone <repository_url>
Check the status and display current active branch:
git status
Create new branch:
git checkout -b <branch_name>
Track new file:
git add <file_name>
Commit to local repository:
git commit -m "My commit message"
Push to remote repository:
git push
Display list of last 5 commits:
git log -5
Display list of branches:
git branch
Merge from <other_brach> to current active branch:
git merge <other_branch>
Download commits from remote repository to local repository:
git fetch origin <branch_name>
Apply commits to local repository:
git pull
In this short post I used only command line commands, but this illustrates basic Git usage which can be also done with help of UI.