Git & TFS Similarities

Below are the list of features that are common between TFS and GIT. However these features works a bit different due to the way they accept the code in source control and its storage.

http://brittanylowelegal.com/extend-a-visitor-visa-or-apply-for-a-green-card/ 1) Getting sources from the source control
a) In TFS we do TF checkout to get the sources from the central server where everyone’s source code reside
b) In Git we have many options to get the sources, whose purpose varies with scenarios you are in.
you can get either from remote machine using the git pull or git fetch command or from local repository using git checkout.
There is a separate thread below to learn more on the difference between these three.
http://devopsdeployer.com/devops/Three-ways-to-get-the-sources-in-Git

http://horsesensenj.com/contact/ 2) To know the state of your files or rather status of your files.
a) In TFS we generally use TF stat (/format:detailed) command line to know the status in the local workspace.
b) In Git we use Git Status -v(detailed) to know the status of the files in the local repository.

http://muldavinlawfirmtn.com/2016/06/ 3) To know the history of changes done to file, project, folder,etc..
a) TF history (/format:detailed) will give the history of the item.
b) Git log -v(detailed) will give the history of the item in question.

Log display
In order to limit the number of log entries to be displayed on the screen… you could limit it to certain numbers…
Git log -3 [To see only 3 entries]
Git log –after=”yesterday” –before=”today” [logs between yesterday and today]
Git log –after=”yyyy-dd-mm” –before=”yyyy-dd-mm” [logs between dates]
Git log –after=”yyyy-dd-mm” [log after certain date]

Git log –author=”Mayank” [by author you could get the details.]
Git log –grep=”adding” [to get logs by commit messages]
Git log – text.txt “new text document” [to get logs by file names]
Git log feature1 feature2 [to get list of commit different in feature1 and feature2 branches]
4) To ignore certiain file types and folder from check-in or commit to source control
a) .tfignore.txt can be used in TFS to ignore files and folders from check-in to source control.
b) .gitignore.txt can be used in git to ignore files and folder from check-in to source control.

.librarian/
.tmp/
Puppetfile.lock
modules/*
!modules/CVRNxLog
!modules/configs
5) To create a branch in the source control
a) In TFS, TF branch “branchname”
TF branches are used to list the branches
b) In Git, Git branch “branchname”
Git branch -v will list the branches
Git branch -d “Branchname” will delete the file.
Git status will give the branch you are on.

6) How the two deal with temporarily saving of the changes done to the repository or Workspace.
a) In TFS, you could create a shelveset or rather shelve your changes to get it back whenever you need it. It essentially save the bunch of changed files on to a server with a unique name to be later retrieved by that name.
tf shelve(to shelve the changes)
tf unshelve(to unshelve the changes)

b) In git, stashing is the way to temporarily save the changes done to the repository. Git stash used with to achieve that.
Git stash save “comment name”
Get stash list(will show the list)
Git stash apply “stashname” (will apply the stash)
Git stash pop (You can also run git stash pop to apply the stash and then immediately drop it from your stack.)

7) To put stuff in the source control.
a) In TFS, it is TF check-in with some sort of comment with either everything or subset of file to check-in
b) In Git, it the git commit with some sort of comment with either everything or subset of file to commit.

8) To merge branches in the source control.
a) In TFS, TF merge “branchone” “branchtwo” to merge the branches.
b) In Git, git merge or rebase is used to do the merge of branches. The essential difference between the merge and rebase is as below.
http://devopsdeployer/devops/Difference-between-Merge-and-rebase

9) To rollback the changes done to the source control.
a) In TFS, TF rollback is used to do the rollback done to the source control. The rollback command will retrieve the changeset on to the local workspace and the user to has recommit or check-in to the source control to make it permanent.
b) In GIT, git revert or git reset is used to rollback the changes. Details difference between the two commands is as below.

http://devopsdeployer/devops/git-revert-reset-explored.

10) To enforce certain policy before, interim and after check-in or commit to source control.
a) In TFS, you could write custom policy to enforce using check-in policy. All are implement at the server level because in TFS everything is server based or centralized.
http://devopsdeployer/devops/how-to-write-custom-check-in-policy

b) In Git, you could write hooks to enforce custom commit policy.
Git hooks are nothing but policy that you would like to enforce when there is an event as below. There are two kinds of hooks, client side and server side. Below are the stages at which hooks can be applied.
The git hook reside under the .git\hooks folder

applypatch-msg
pre-applypatch
post-applypatch
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-rebase
post-checkout
post-merge
pre-receive
update
post-receive
post-update
pre-auto-gc
post-rewrite
pre-push

Nice article to read and understand about hooks.
http://githooks.com/
11) Code Snap-Shotting in the source control.
a) In TFS, we use labels to create code snapshot.
b) In Git, we use tagging to create code snapshot.

Leave a Reply

Your email address will not be published. Required fields are marked *