The Github for Windows Users Installation and User Guide

Github just published their software for Windows. It comes with many features and security. On this post I'm going to write about installation and user guide of this software.

If your project is only stored on your disk, then a disk failure you expect trouble. Even regular backups are not always able to save you.

Some developers may bloat in the project so much that they themselves in shock. And remember what was done and where is difficult. That is still a nuisance.

A version control system can help you avoid these problems. If necessary, you can make a recovery or rollback changes. View and confirm or cancel the changes. But teamwork without a version control system is unthinkable.

If you suddenly do not know, I want to introduce you to a little version control system called Git. Under the cut you expect a description of how to use GitHub with Visual Studio.Current expansion called GitHub Extension for Visual Studio. It is suitable for Visual Studio 2015 or higher.Download vsix possible to github page or the Visual Studio, gallery The .

Install the extension and possible when installing Visual Studio:

Before continuing, you need to learn a few terms. If you know them, then dissipate down.

The Push – sending changes from a local repository in GitHub repository.

The Merge – merge. Applying changes committed in another repository current repository. Something like combining the two repositories.

Pull – a combination of fetching and merging. First, from a remote repository in a list of changes, and then the changes are applied to the current repository.

That is, if someone but you worked and made changes to the GitHub repository, you can consistently make two steps: Fetch, then the Merge. Or you can directly perform the Pull. After this, the committed changes in your local repository.

After installing GitHub Extension for Visual Studio, Team Explorer panel will look like this:

If Team Explorer bar is hidden, you can display it via the “View Take” menu / “View”. Connecting to GitHub (clicking Connect … and entering a username and password) will get the opportunity to clone the GitHub repository or create a new one (the buttons Clone and Create):

Cloning will see a list of repositories to which you have access:

When you create a repository, you can enter the name, description, and select the license under which the code is allowed to use:

In this case, Git ignore contains presets for different types of projects. And I’ve found this .gitignore format is intended to indicate in it what directories and files you want to exclude from the version control system.

In case you want a very well hidden from prying eyes cutlet repository, you can mark it as Private. But this requires a paid subscription.

For students GitHub is offering a special – Student Developer, Pack , which in particular includes free unlimited number of private repositories.

After creating the repository to create a project. Personally, I prefer the other way around, first create a project, and only then to add it to Git. It is possible to create the project and set up a Git repository. To do this, tick enough.

If this check box when creating a project does not deliver, but simply open the project in the VS, in the File menu item will be available «Add to Source Control» / «Add to Source Control”

After pressing it, the project will be added to version control of Git, and .git folder inside the local folder will be created with the project. In Team Explorer, it will look like this:

Switching between the Team Explorer and Solution Explorer can make some changes in the project. After any changes, you can make a commit – a kind of a restore point. To do this, go back to the Team Explorer, the menu of which there is a button with a painted on her house. Clicking on it takes you to the main menu:

“Changes” button / “Change” will commit your changes (in this case necessarily must specify a comment with a description of the changes). But all the actions so far will be made only to the local repository, the git.

When you create a project, sometimes created by the so-called «Initial commit», which is written something like “The project was created for three days.” If you have just created a project, then changes it so far yet.And if there is no change, then commit to create not work. I have added a line with the text, so the comments have tried to describe it briefly, but it is clear:

You can see the committed changes. To do this, we are interested in the file you need to open the context menu and select the «Compare with Unmodified …» / «Compare with unchanged …”

We get about a comparison here:

In this case, only two lines of code have been added. Within the same context menu of all the changes that have occurred since the last commit, you can undo. A very handy feature.

Now, let’s move back to the main menu by pressing the house. In order to send the changes to the GitHub you must click «Sync» / «Synchronize».

Since our project has not yet been published on GitHub, then we will offer to do this:

By the way, it is possible to publish .git not only on the GitHub, but also on the Visual Studio Team Services.

If we publish the project before, the list of outgoing fixations will be located our commit:

Pressing Push will send all changes to the repository is located on a server GitHub.

Having made some changes to the sample directly from the browser in the repository located at GitHub (yes, that is also possible), I again went to the synchronization and pressed Fetch:

Here you can double-click to open information about the commit:

And already by clicking on the image to see the changes:

In the same window, you can view the synchronization history:

History can be viewed in plain view and in detail:

Now, let’s imagine that we work as a team and someone else has already made some changes in its local repository and sent out into the GitHub. You also made changes to the same file in the same row. In this case, when you synchronize with GitHub you have a conflict arises:

Clicking on Conflicts get a window here in which, after clicking on a file opens a menu with the button Merge:

Now we can put a tick to choose the changes that we want to leave in the final version. Final version in the following screenshot is displayed below. it is also possible to edit code:

After making the changes you need to click Accept Merge (in the upper left corner), and then make a commit:

Github Desktop and PowerShell environment for Git

Github Desktop – Utility completely independent and with Visual Studio has nothing to do. You can download it here .

The utility is available for both Mac and Windows users. However, it is set and the command line Git Shell. In fact, it is a set of PowerShell scripts to integrate with Git. Called PowerShell environment for Git. Shorten-posh git.

On GitHub project page posh git- you can find brief instructions on how to install the command line for posh git hand.

I will not consider itself utility interface and work with it. I think that it is not difficult and you will be able to deal with it themselves. Let’s play a little with the command line. Unlike GUI command line generally offers much more possibilities. However, we consider only the basic commands.

To view the current configuration and make sure that there is Git, you can run the command:

git config –list

In order to clone the repository to perform sufficient command the git the clone . For example:

After running this command, the folder with the project will be in the current directory. Also http: // and https: // are supported, and SSH, and git: // protocol. If you go to a project folder using the cd (in the case of the example cd BarcodeScanner), then the command line will be transformed:

PowerShell The status bar displays the text of a posh ~ the git , which means that you are in a PowerShell environment for Git. You need to run the git the status , to know whether to synchronize the local repository is required. The answer might be:

The most popular teams are the ones that we have already considered as part of the expansion interface the VS: the git the fetch , the git the merge , the git the push . If you go to the directory (folder name PortableGit_xxx, I believe, may be slightly different):

you will find there are many executables that simulate command. As already mentioned, git certificate can be used, but, let’s try out a few commands for example.

For example, if a new file appears in the directory of the project, the git status command returns:

And that means you need to add the file command the git the add the index.html . Now we need to confirm the changes using the git the commit . This command will open a text editor, which is installed by default. It must be the first line enter the text describing the changes committed. If you start the line with a # character, it will be a comment. Comments can be left in the lines below. If you do not leave any text describing a commit, the commit will not happen. You can specify the text immediately commit on the command line using the -m option. For example: the git the commit -m «the File added the index.html»

Now you can use git push to send changes to the GitHub repository. If this is your repository. Alien repository you can copy to yourself by creating a so-called branch – Fork. Having made some changes, you can offer them to the author of the original repository creating a pull request.

This let to complete the description of the possibilities to work with GitHub for Windows users. If you want to continue to explore, then you can see the MVA course GitHub for Windows Users