Introduction to git for Beginners (Tutorial) Jignasha Rathod December 18, 2019 3 min read Git is one of the best Version Control Systems which is used in software development.Advantages Of Git: Faster Only one directory per repository Can work with branches, developers can work on multiple tasks with branches if needed Versions can be managed within a single directory Allows to create a branch, commit code locally Can copy changes from one branch to another branch easily Can use commands to work with gitGet the latest on ‘main’: switch to ‘main’ branch by double-clicking the branch click Pull to get the latest versionCreate a new feature branch: Right-click ‘main’ and select ‘New Local Branch From…’ Naming convention for feature/bugfix branches: ‘feature/#TaskId_title_of_work_item’ or ‘bugfix/#BugNo_ID_title_of_bug’ Do not use spaces or special characters in the feature name The ‘feature/’ and ‘bugfix/’ prefix is lowercase Name the new branch as ‘feature/#name_of_the_story_or_bug Commit changes to your new feature branch: To see your changes go to the Team Explorer tab and select Changes. Add meaningful comments to your Commit and also associate a work item with the commit: Add comment Stag changed files Click Commit Stagged Merge the latest main branch to your feature branch:When a branch is ready, first merge the latest ‘main’ to your feature branch. Make sure you commit every change to your feature branch. Switch over to ‘main’ and pull the latest version. Switch back to your feature branch and right click ‘Merge From …’ Select main in ‘Merge from branch’ and select ‘Commit changes after merging’ Save changes (git stash):Sometimes there are pending changes in your work space you don’t want to commit but want to save. You can shelve changes with git stash. To save pending changes:git stash git stash // save pending changes git stash list // list saved changes git stash apply // apply the latest saved change git stash drop // delete latest saved change git stash clear // delete all saved changes git stash pop // apply the stash and immediately dropIn this example, I have two saved changes:To apply the first saved change:git stash apply: git stash apply stash@{0}Also Read: PIVOT and UNPIVOT Operator in SQL Server – C# Example CodeVisual Studio 2015 problems:Resolve error message about uncommitted changesSometimes you cannot switch between branches, or cannot merge/pull as VS2015 shows an error about uncommitted changes – however when you look at “Changes” there is nothing pending.This is a VS2015 issue and to get around it, do the following: Open a Git bash command line in your git / ODS eCommerce folder Run the command: git status Confirm that there are no pending changes Go back to VS2015 and try to do your merge/pull / etc action again – it should be fine nowResolve the merge issue.Sometimes you cannot merge the latest main into your feature branch even after you did a “git status”.In this case, you can fall back to your git command line and try merging there: Switch to the target branch you want to merge to Open Git bash command line in your git / ODS eCommerce folder Run “git status” and confirm there are no pending changes Run “git merge main“ Go back to VS2015, allow reload all changed files and go to “Changes” You might have conflicts to resolve If there are no conflicts then Commit your changesRefresh local feature branches when they deleted on VSTS.At the end of a pull request feature and bugfix branches going to be deleted by default.VS2015 does not automatically exclude deleted remote branches until you run this git command.cmd: git remote prune origin –dry-run git fetch –prune -OR- git remote prune originUseful links: VSTS Git Tutorial(https://docs.microsoft.com/en-us/vsts/repos/git/gitworkflow) Git command line(https://docs.microsoft.com/en-gb/vsts/repos/git/mapping-my-tfvc-actions-to-git?) Pull requests(https://docs.microsoft.com/en-us/vsts/repos/git/pullrequest) Git command line reference (git-scm)(https://git-scm.com/)