Add a console application to the solution using Solution Explorer. Write some code and you will see there are three options to commit…
- Commit All (only to local repo),
- Commit All and Push (local as well as remote repo)
- Commit All and Sync (to remote and also fetches changes from remote if any).
Provide a comment and select Commit All. You can confirm that there is no code committed to the remote repo by using browser.
Branching and Merging
Branches: Branching is a very common feature when we have to do parallel development. This way, the changes can be kept separate. Bitbucket provides a master branch and we can create multiple branches in local repository as and when required.
Branching will usually be followed by merge to the truck or master branch. Forking is a way of creating a branch but that will not merged.
We can observe the master branch by going to Branches in Team Explorer. A new local branch can be created by right clicking on existing branch and providing a name to it.
We can find the information about the branches like who created it, when was it merged, if not merged, how much is it lagging behind etc.
Fetch and Pull: In both fetch and pull, the repo is downloaded from remote repo. Fetch is used to update remote tracking branches, it doesn’t integrate with working files. It helps a repository up-to-date but we can keep on working on something else. Pull merges into the current branch. Pull is a combination of fetch followed by merge.
When a developer is working in a dedicated branch and creates a specific feature he/she can create a pull request to get feedback, reviews from peers. The developer then creates a pull request via Bitbucket. The other team members then review code, discuss it and can change if required. It is essential to have a branch for creating a pull request.
You can add reviewers(s), and the pull request automatically specifies the changed files. If there are any open pull requests, they are also shown.
We can set certain features like which tool to use for merge and what files should be added to .gitignore in following manner. Files which are not to be tracked will be ignored. You can put patterns in .gitignore files which will be ignored in git.
Visual Studio is set for Diff as well as Merge. In case of any conflict, Visual Studio will show the conflict and we can resolve the conflict before commit.