Git extensions руководство пользователя

This is our GIT extensions tutorial for beginners. Here’s what you are going to learn:

  1. Introduction to Git Extensions
  2. Managing Repository
  3. Generating SSH Keys as a One-Time Activity
  4. How to Clone a Repository?
  5. How to Open a Repository?
  6. How to Traverse into the Repository?
  7. How to Track the Changes using Git Extensions?
  8. How to Perform Commit & Push?

Introduction to Git Extensions

GIT Extensions is a distributed version control system enabling a user to robustly manage a collection of source files and the changes made in them. The changes made are shown in the History of changes. Users can make changes by accessing a Central repository called remote repository and committing the changes to it. It implements classic GIT by using GUI (Graphical user interface), basically driven by a set of dedicated commands, hence maintaining the version control system intuitively. So, let us go through a glimpse of functionalities provided by GIT Extensions so that our version control system can be maintained.

Managing Repository

There are many options to manage the repository through GIT Extensions. It includes viewing the committed logs and changes made in comparison to the previous commit, cloning a repository, traversing through the file directory and filtering the committed logs by using custom search input, etc.

GIT Extensions can be downloaded from https://github.com/gitextensions/gitextensions/releases/tag/v2.48.05

Generating SSH Keys as a One-time Activity

SSH Keys should be loaded as a one-time activity. SSH keys can be generated while setting up the GIT Extensions.

In order to use a safe development environment with SSH, you need to get PuTTY installed as a preferred SSH client. PuTTY can be downloaded from http://www.putty.org/

The first thing is to check that Git Extensions is properly configured to use PuTTY, as well as all paths, are given correctly.

In the Remotes Tab just choose Generate or import key to start the key generator.

Configure Git Extensions use PuTTY

Putty Key Generator

It will ask you to move around the mouse in order to generate more random keys. When the key gets generated, save the public and private key in a text file by clicking the Save Public key button.

Save Public Key

Since now you are having a key pair, provide the public key to the Github account by copying the Key from the file which you just saved above at your desired location.

Then open your Github account and click on the profile image, followed by Account settings and going to the SSH Keys tab. Finally, paste the public key over there.

You can create a Github account at https://github.com/join?source=header

Setting up SSH Public Key

Now GitHub will get to know which public key it has to use to decrypt. Now you also need to provide the private key to GitExtensions to encrypt. You will find a Load SSH key button in the clone dialog where you can load the private key in PuTTY authentication.

Note: This is a one-time activity and you don’t need to repeat these steps again.

How to Clone a Repository?

Cloning a repository will create a local copy of the repository being cloned by this action.

It’s possible that the repository you want to clone is located on a network share or is accessible via an internet or intranet connection. You may need to load an SSH key into PuTTY depending on the protocol (http or ssh). You must also indicate the location of the cloned repository and the branch that will be checked out first. If the cloned repository has submodules, they can be initialized with their default values if necessary.

When making a clone, you can create two different sorts of repositories. A personal repository stores all of the histories as well as a functioning copy of the source tree. A central (bare) repository serves as a public repository to which developers push updates that they want to share with others. A central repository holds the entire history but does not have a working directory, unlike personal repositories.

  1. Click the ’Clone repository’ link from the Common Actions section on the left to clone a repository.Clone repository Location
  2. Provide the necessary inputs as Repository to clone (highlighted URL at the top tells which repository needs to be cloned), Destination (local hard drive location), Branch (automatically loaded when the local repository address is provided), and Repository type, and then click ‘Clone’.Adding Clone repository details
  3. The process of cloning starts and the remote files are checked-out to the specified destination i.e. local directory. A green tick mark indicating completion of the process will be displayed.Successful Check out files

Note: A Red Cross mark with respective errors will be displayed too during the occurrence of errors in the process if any.

Errors in Cloning – Troubleshooting

You’ll likely get some issues when cloning a repository. If you’re having trouble cloning a repository, make sure:

  • You can use HTTPS to connect.
  • You have access to the repository you’d like to clone.
  • The default branch that you’d like to clone is still available.

How to Open a Repository?

From the Common Actions section at the left click the ‘Open Repository’ link and give the directory address for opening a repository. Then click the ‘Open’ button as highlighted in the figure.
Figure3

It opens the repository and all committed logs will be shown with an abstract message associated with them, committed user, and the time elapsed when the commit was done (Refer figure). Also, the details like Author, date are shown at the bottom in the commit section.

Repository view

How to Traverse into the Repository?

Initially click the ‘File Tree’ tab. It will show the whole repository in the form of a file tree and intended files and directories can be viewed easily. This is the step-wise procedure to traverse a repository by a user.Using File Tree to traverse a repository

Using libgit2

Let’s have a peek at the source code.

#include <git2.h>

This header file must be included in any program that uses libgit2.

The first step is to use git libgit2 init to get libgit2 and its resources up

int main(int argc, char * argv[])
{
    git_libgit2_init();
   const char * REPO_PATH = "/path/to/your/repo/";
   git_repository * repo = nullptr;
   git_repository_open(&repo, REPO_PATH);

You open a repository with git repository open, which creates an object that you may use in your code to interact with a repository.

git_revwalk * walker = nullptr;
git_revwalk_new(&walker, repo);

The next step is to develop a revision walker, which is an object that iterates over a git repository. The git revwalk new function handles this.

git_revwalk_sorting(walker, GIT_SORT_NONE);

Once we’ve created a revision walker, we’ll need to provide a few parameters to manage the traverse. One example is the sorting mode when iterating over the repository. This is accomplished by invoking git_revwalk_sorting with one of the following values as the second parameter:

GIT SORT NONE – the default reverse chronological order (beginning with the most recent) of commits as in git

GIT SORT NONE – the default reverse chronological order (beginning with the most recent) of commits as in git

GIT SORT TIME – order of commit timestamps

GIT SORT REVERSE – performs commits in reverse order.

An OR can also be used to combine topological and temporal ordering.

It’s worth noting that you don’t need to use this function to set GIT_SORT_NONE because that’s the default setting.

git_revwalk_push_head(walker);

We are now ready to begin the traversal after the setup stage. This is accomplished by the method git revwalk next, which obtains the ID of the next commit to visit.

Calling git_revwalk_push_head changes the root to the HEAD of the repository.

git_oid oid;

    while(!git_revwalk_next(&oid, walker))
    {

Once we have used the commit, it’s time to release the object calling git_commit_free.

git_revwalk_free(walker);
git_repository_free(repo);

We are now ready to begin the traversal after the setup stage. This is accomplished by the method git_revwalk_next, which obtains the ID of the next commit to visit.

git_commit * commit = nullptr;
git_commit_lookup(&commit, repo, &oid);

Once we have an ID, we can use git commit lookup to retrieve a git commit object. This object will be used to retrieve information about the commit.

std::cout   << git_oid_tostr_s(&oid)
                    << " "
                    << git_commit_summary(commit)
                    << std::endl;

This is where we collect the necessary information from the ID and the commit.

After we’ve utilized the commit, we’ll call git_commit_free to release the object.

git_revwalk_free(walker);
git_repository_free(repo);

We can extract the hash of the commit from the ID using git_oid_tostr_s and the short summary of the commit using

git_commit_summary.
git_commit_free(commit);
    }

Then we may call git_revwalk_free to free the revision walker and git_repository_free to free the repository.

git_revwalk_free(walker);
git_repository_free(repo);
git_libgit2_shutdown();
return 0;
}

Finally, we shut down libgit2 with git_libgit2_shutdown.

How to Track the Changes using Git Extensions?

By clicking the ‘Diff’ tab comparison can be made with respect to the previous commit as shown in the figure.

Using Diff tab to track the changes

Press Ctrl+click commits to see all changes between them in the Git Extensions GUI. Because the first pick is handled as the base, choose an older commit first to show the change direction in diff view (additions/deletions) appropriately.

AFAIK, Git Extensions does not offer a GUI option to send a directory diff to an external tool (just file by file); therefore, you must do it from Git shell to obtain all changes at once to Beyond Compare (assuming you have configured it as a diff tool for Git).

git difftool -d <commit1> <commit2>

If you want to compare your current checked-out version to <commit1>, omit <commit2>. For instance, if you are on your local master and use fetch rather than pull

git difftool -d origin/master

will display the modifications that will be made when your local branch is merged with the origin branch.

Note: Newly added lines are marked as ’+’sign and shown with green color and the deleted ones as ’-’ sign and presented with red color.

How to Perform Commit & Push?

This action of committing and then pushing the given code to a remote repository is divided into two operations:

  1. Committing to Local Repository
  2. Committing to Remote Repository

Committing to Local Repository with Git Extensions

This process of committing involves various steps:

  1. To start the process click the ’Commit’ icon.Commit Process
  2. The respective fields are displayed in the newly opened commit window (Refer figure):
    • Working directory files.
    • Staged files.
    • Details of the modifications compared to the respective repo code.
    • Input box for the commit message to be entered by the user.Commit section
      The top left section will show the working directory files which were modified since the last commit:

      1. Click any file from the working directory file list. The files with their modified changes (highlighted in Red and Green) are displayed on the right section. This way we can identify file-wise discrete changes.
      2. When the changes are verified, files can be staged by using the ‘Stage’ option (Refer Figure). These Staged files are ready to commit and provide an easy way for filtering certain files not committed during the previous stage for the users.Staged Files in Commit Window
        Note:
        Users can also Unstage a staged file by using the ‘Unstage’ option opposite to Stage icon.
      3. When the verification and staging of all required files are done, you have to provide a suitable message to show the current commit action. The Commit History screen will show this message. The purpose of committing an action can be easily interpreted in an appropriate message is given.
  3. Commit the files using the ‘Commit’ button. The status of the commit operation is displayed in a dialog window. It will also show all the run-time errors of the process, displaying them with the appropriate stage of the whole process.

Note: Clicking ‘Commit’ lets the files be committed into the local repository and not into the remote repository.

Commit changes

Committing to Remote Repository

‘Push’ action is used to move the files of the local repository into a remote repository. It needs to be ensured by the user that the code which was taken lastly from the remote repository is not modified before you perform push action. There is every possibility that a repository could have been modified when it has been pulled or cloned by another person. This generally happens in a multi-user environment where a lot of branching and merging happens. Hence, it is necessary for a user to perform a Pull before opting for a Pushing action for the committed code.

Pulling the Code

  1. Open the pull Window by clicking on the ‘Pull’ icon as shown in the figure. Provide the remote repo URL and select the remote branch from there.
  2. It is necessary to select the Do Not Merge Option (Do not merge, only fetch remote changes) and ‘Auto Stash’ option.
  3. Lastly, click the ‘Pull’ button.Pull code before pushing
    PullImage

Pushing the Code

As of now, the local repository and the remote repository are in sync, so the user now has to click the ‘Push’ button as shown in the figure so that all the locally committed changes can be pushed to the remote repository.

Figure 11

Push code

We hope that this tutorial helps you in getting familiarized with the use of Git using the tool Git Extensions.

 
 

About the Author

ByteScout Team

ByteScout Team of Writers

ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.
 

Git Extensions Manual

This repository contains the new Git extensions Manual. Feel free to help us improve this manual by sending pull requests
or by opening issues.

Refer to the Wiki here: https://github.com/gitextensions/gitextensions/wiki for details on how to update the documentation.

View Online

The current documentation can be viewed here: https://git-extensions-documentation.readthedocs.org/

PDF and other formats can be downloaded here: https://readthedocs.org/projects/git-extensions-documentation/downloads/

Note: Only the HTML format is «supported» (i.e. from the display point of view). Other formats might have layout issues
but the content remains the same for all formats, whether or not you build it locally (provided your local clone is
up to date).

Build

To generate the documentation, you need to have Sphinx installed: https://www.sphinx-doc.org/en/master/usage/installation.html#windows
The following installs and build the GE html documentation for any Python package with PIP included:

  • pip install -U sphinx
  • sphinx-build -b html -d build/doctrees source build/html

If you have docker installed, you could also generate the documentation using the command in a cmd prompt (or run the file make-html_docker.cmd):

docker run --rm -v %CD%:/docs sphinxdoc/sphinx sphinx-build -b html -d build/doctrees source build/html

HTML

Simply run make-html.cmd. You can also use make-singlehtml.cmd to generate a single HTML
file. The make_and_start_Browser.cmd is an alias of make-html.cmd that will open in your
default browser the documentation main index.

HTML Help Files

Warning: This format is not completely supported (i.e. you can generate it but we don’t
guarantee as good a display quality as for HTML).

Download HTML Help Workshop (https://www.microsoft.com/en-us/download/details.aspx?id=21138).

To build the file, use make-HTMLHelp.cmd

PDF

Warning: This format is not completely supported (i.e. you can generate it but we don’t
guarantee as good a display quality as for HTML).

To use the PDF builder, you’ll need to install:

  • rst2pdf easy_install rst2pdf
  • pil easy_install pil

Also add ,'rst2pdf.pdfbuilder' to the source/conf.py file at the line 28. Then run make.cmd pdf.

Version update

  • Set version in source/conf.py
  • Create release branch release/x.y (this is the default from the GE About menu for released versions, ‘master’ for development builds).
  • When releasing final, push ‘latest’ branch to release/x.y commit (this branch is the default when browsing https://git-extensions-documentation.readthedocs.io/).
  • Edit versions in https://readthedocs.org/projects/git-extensions-documentation/versions/ (admin privileges needed). Keep relevant versions active.
  • Trigger a build for changed versions

This tutorial indeed for people who is not familiar with Git and GitHub and make first steps with this this technology. The tutorial contains following steps:

  • Installing Git and Git Extensions
  • Setting up GitHub account ,SSH keys and repository
  • Working with GitHub repository with Git Extensions
  • Cloning public repository from GitHub

Installing Git and Git Extensions

Git Extensions is an open-source project provides graphical user interface for Git that allows you control Git without using the command line. It’s download includes msysgit — implementation of Git for Windows.

Download and run latest build from download page . I use version 2.29 for this tutorial. Follow installation wizard with taking notes below:

When you run installer you get welcome page:

 Go next till you get «Required Software» page:

Since Git Extensions is only graphical tool, it requires Git installed. If you are not sure you have proper git installation, just select option «Install MsysGit». KDiff is a diff/merge tool, not the best one, but free. I recommend you select it as well.

Go next till you get «Select SSH client» page:

Ensure you select «PuTTY». It is an easiest way to work with SSH on Windows.

Go next till you get MsysGit installer running (as part of Git Extensions installation).

Select following settings during installation (it is can be changed after installation).

Finally you get «Complete installation»  page with «Finish» button.

Congratulations! You have Git and Git Extensions installed. Run it!

When you run Get Extensions for fist time, it comes with settings page with error:

Don’t be scared, it is normal for first time. Just click «Repair» and fill missing details 



That’s it. Now you are ready to work with Git repository.

Setting up GitHub account ,SSH keys and repository

Go to https://github.com/signup/free to set up you free account. Registration process is very simple. If you already have GitHub account, skip this step.

Once you have an account at GitHub, log in and go to your account SSH keys configuration page https://github.com/settings/ssh. If you first time here, you have an empty list.

Now it is time to create your SSH key. You may follow instructions from GitHub, but I want to show you my way.

When we installed Git Extensions, we selected «PuTTY» as SSH client and it resulted with helpful  PuTTY utilities was installed. You may find them in C:\Program Files (x86)\GitExtensions\PuTTY folder (or C:\Program Files\GitExtensions\PuTTY on 32bit Windows)

pageant.exe — PuTTY SSH authentication agent,
plink.exe — PuTTY SSH client,
puttygen.exe — PuTTY SSH key generator.

Run puttygen.exe, click «Generate» button and move mouse over black area while progress is displayed.

This way you generated your SSH key.

Now save private key (you may select passphrase (password) if you want). Note: you have to keep you private key in secret.

Copy text from textbox above — it is your public key.  This is what you put into your GitHub account. You can always get this public key by loading your private key in puttygen. (File > Load private key).

Not it is time to come back to GitHub https://github.com/settings/ssh.

Click «Add SSH key», give a name for this key and copy you public key from puttygen.  Click «Add key» —
SSH Keys list shows your newly created key:

Creating repository is very simple. From main page (https://github.com/) click «New repository», fill the form and click «Create repository» — you will get instructions how to set up Git. You may follow this instructions, or follow my way I used to go.

Working with GitHub repository with Git Extensions.

First of all you have to know your repository url. Take it from GitHub instruction page:

Open Git Extensions and click «Clone repository»

Fill repository url and destination. Then click «Load SSH key».

 

Select you previously saved private key and click «Load». It might prompt password, if you set up one when saved the private key. 

Loading SSH key required for authentication against GitHub.

Click «Clone». Git Extensions will create destination directory and initialize local git repository there.

Click «OK» — it prompts with «Open repository» dialog.

Click «Yes» — your newly cloned repository will be opened:

Such screen you will see each time you clone an empty repository. Lets do some changes.

Go to repository directory and create new README text file:

You will see there .git folder.

Don’t modify or delete it

. This is actually Git repository. All files and folders beside are only current checked out branch.

Now go back to Git Extensions and click «Commit». You will get commit dialog:

Our newly created file have no persistency in repository, Click «Stage» to «fix» it.

Now it is ready for commit. Put commit message and click «Commit».

Git Extensions shows this first commit in our local repository (red colored label).

But it is not all. Since this is our local repository, we have to deliver our changes to remote repository at GitHub.

Go to menu «Commands» > «Push». It opens «Push» dialog:

Click «Push». Because there is no master branch in remote repository yet, it opens confirmation dialog:

Click «Yes».

Now Git Extensions shows your remote repository branch (green colored label)

Since we have created master branch in GitHub repository, it’s page doesn’t show Git set up instructions, but all repository related information:

All further commit with this repository are similar to first one. You make changes, stage them, commit and push.

Cloning public repository from GitHub

If you want to clone some public repository from GitHub, you have to follow the same steps as you clone your own repository.  The difference is in  repository url. To obtain repository url go repository page.

There is my repository page for example https://github.com/manishma/IZWebFileManager:

In case you select read only access url, you even don’t need to configure SSH key. (You still need it for read-write access).

Authentication failures and loading SSH key

When you open local repository with Git Extensions and want to update or  push you changes from/to remote GitHub repository,  you might fail into authentication error:

It happens if your SSH key has not been loaded yet. Don’t panic, click «Load SSH key», select your SSH private key and then click «Retry».

Thank you

I hope you find this tutorial helpful.

If you have any questions, please put your comment here.

Ну и рассмотрим еще этот инструмент. Качаем тут.

GE0000

Git Extensions в установке по умолчанию идет сразу с msysGit и KDiff3, мне это не надо, так как у меня все это уже стоит. Версия без них весит куда меньше. В данном случае 9.3Мб против 38Мб.

Можно так же скачать и портабельную версию, но с ней могут быть вот такие проблемы при запуске

GE0005

Так что качаем ту что посрединке и устанавливаем

GE0006

GE0007

GE0008

GE0009

Так как у меня PuTTy уже стоит в комплекте с TortoiseGit, то я выбрал его. Правда потом пути к нему надо прописать в настройках Git Extensions, но он даже сам подскажет как это сделать.

GE0010

GE0011

Если возникает такая ошибка то это легко правится кнопкой Repair, надо просто указать путь к sh.exe в каталоге Git. Но он сам находит этот путь.

GE0002

GE0003

Далее может быть ошибка что не увидит PuTTy. Это тоже легко правится

GE0012

GE0013

GE0014

GE0015

GE0018

Ну и запускаем тулзу

GE0016

GE0017

Все в принципе достойно.

Понравилась статья? Поделить с друзьями:
  • Газовый котел wolf fgb 35 инструкция
  • Menzerna полировальные пасты инструкция по применению
  • В числе прочих инструкций граф поручил мне дать понять его
  • Руководство tomahawk 9020
  • Полисорб инструкция по применению при алкогольном отравлении