VS with Git, vswithgit

Source: Internet
Author: User

VS with Git, vswithgit

  • Know Git
  • Test Environment
  • Add to remote Repository
  • Clone from remote Repository
  • Submit changes
  • Synchronization
  • Member and permission management
  • Manage branches, create and merge branches
  • Resolve Conflicts
  • TFS code migration to Git
Know Git

Git is currently the most advanced distributed version control system in the world. Compared with the distributed version control system, there are also centralized version control systems, such as TFS.

In a centralized version control system, the version library is centrally stored on the central server. When working, it uses its own computer. Therefore, you must first obtain the latest version from the central server, then I started to work, finished my work, and pushed my work to the central server. The central server is like a library. If you want to change a book, you must first borrow it from the library, then go home and change it. After the change, you can put it back to the library.

The biggest problem with a centralized version control system is that it can only work online. In addition, if a central server has a problem, no one can work.

The distributed version control system does not have this problem, because each user's computer has a complete version database. Before synchronization, all operations can be completed in the local repository.

Centralized version control system:

Distributed version control system:

The local operation flowchart of the distributed version control system:

The concept of working directory, temporary storage area, and local warehouse is very important.

Working directory: the directory where the solution is located.

Temporary Storage Area: added but not submitted to the local repository.

Local Repository: the local version that has been submitted, relative to the remote repository.

Test Environment
  • Vs2015
  • GitLab
  • Cancel IE proxy and disable fiddler
Add to remote Repository

Add an existing project to the GitLab.

For example, to add a local project HelloWebAPI to GitLab, perform the following operations.

1. Right-click the solution, select Add solution to source code management, and open the select Source Code Management window. You can also open the select Source Code Management window by opening the menu "file/Add to source code management", as shown in

2. Select Git and click "OK". In the displayed change window, write a note and click "Submit". The project has been added to the local repository but has not been released to the remote repository.

3. Before publishing to a remote repository, you must create a remote repository on GitLab.

Click Create Project to Create a remote repository.

Copy address, which will be used below.

4. release to the remote repository.

Click the release button to see that the release is successful.

Go to the GitLab project home page to refresh the page. You can see the submitted records, as shown in.


Clone from remote Repository

Adding a project to a remote repository is based on an existing project. Cloning a project from a remote repository does not exist locally. to clone a project from a remote repository, perform the following steps.

1. Git global settings. You can set the user name, email address, and repository location. The user name and email will be displayed in your submission record. The repository location allows you to unify the path for cloning the remote repository, as shown in.

2. Copy the url of the remote repository you want to clone, for example.

3. Enter the connection window of the team resource manager, paste the copy url in the local Git repository, and click the clone button to create a local repository, for example.

You can double-click to open the project.

Submit changes

After cloning the remote repository to the local machine, we can develop it locally and submit the changes.

1. Check out the code and modify it.

I added a sentence to the readme file.

2. Submit

Right-click the solution and select submit to go to the change window of the team resource manager.

Enter comments and click Submit to submit the code,Note that it is only submitted to the local repository, not the remote repository.

The submit button has a drop-down menu, which will be described later. Click Submit (1st) first.

3. Synchronization

To publish local changes to the remote repository, we also need to perform synchronization operations, as shown in.

We will talk about it later, regardless of how to obtain, pull, and push the information.

Message submitted successfully

Check the remote repository and you can see that the synchronization is successful.

Synchronization

Enter the synchronization window to the team resource manager, as shown in.

Let's take a look at the functions of these buttons.

Push: update changes to the local repository to the remote repository.

Get: obtain all input commits before pulling.

Pull: Get the latest version from the remote repository.

Synchronization: synchronization actually performs two operations at the same time. First, pull the latest version (pull) from the remote database, and then compare it with the local database for automatic merge (merge) push to the remote repository.

1. Get the latest version.

To reduce conflicts, you can obtain the latest version before developing new features. There are generally two methods to obtain the latest version, depending on the actual situation.

1) Get and pull. In the input submission item, you can see the submitted changes of other team members. You can pull all or pull one of the changes to the local device.

2) synchronization, because the synchronization will perform two operations at the same time, pull and push. Therefore, this operation is suitable for the scenario where the local repository does not have the changes to be pushed, because if there is a change to be pushed locally, it is easy to cause a conflict.

2. Submit changes

After a feature is developed or a bug is fixed, changes are submitted to the remote repository.

1) Push: You can push all local changes at a time or submit one or more pushes.

2) synchronize. You can also click synchronize to submit changes. Of course, you 'd better pull the latest version before synchronization to reduce conflicts.

Member and permission management

1. Entrance

There are two ways to Add members. Add members is to Add members from the personnel list, and Import members is to Import members in batches from other projects.

2. GitLab provides four roles by default. To allow a Member to submit changes, set the role to Master. Otherwise, an error is returned.

Manage branches, create and merge branches

1. Create a branch

Go to the branch panel, right-click the current branch, and select create local branch from the selected item.

Note: If you want to create a branch from a local database, you are advised to obtain the latest version. If you choose to create a branch from a remote repository, you are advised to submit local changes first.

Enter the branch name and click Create branch.

After successful creation, the Branch is released, which pushes the branch to the remote repository.

The branch 2015.07.29.HelloWebAPI1.0 has been pushed to the remote repository.

2. merge branches

To simulate the actual situation, first make some changes on the branch 2015.07.29.HelloWebAPI1.0, submit the changes, and then merge the branches to the main line.

Add a new record in test2.txt and submit the changes to the local repository.

Switch to the branch window, switch to the master branch, click the merge button, select the source branch 2015.07.29.HelloWebAPI1.0 from the branch merge, select the target branch master, and click the merge button to start merging.

Merge, submit change success prompt

The branch update code has been merged.

Push changes to the remote Repository

Go to GitLab and you can see that the submitted change record and the main line code has been updated.

The main line code has been updated.

Resolve Conflicts

When two or more Members in the team modify the same code segment of the same file at the same time, the person who submits the change or obtains the update will encounter a conflict.

1. conflict occurs

Take the masterline file test1.txt as an example. If the two modify it at the same time.

John added two lines of code in lines 3rd and 4 of test1.txt and submitted them to the local repository.

Li Si also added two lines of code in lines 3rd and 4th of test1.txt, and submitted the changes and pushed them to the remote repository.

If James pushes the push again, the conflict will occur.

2. Conflict Resolution

First obtain and pull the latest, and then resolve the conflict.

Get and pull the latest version

Click the Conflict Resolution link to enter the Conflict Resolution window.

Click merge.

Select both the source and target changes, and click "Accept merging ".

Merge submission

GitLab updated

TFS code migration to Git

Due to the time relationship, no research has been conducted for the moment. There are two articles for your reference.

1, http://www.cnblogs.com/sorex/archive/2013/03/11/2954095.html

Http://chriskirby.net/migrate-an-existing-project-from-tfs-to-github-with-changeset-history-intact/ 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.