Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The basis of git-- Common operations under Windows

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Write at the front:

The use of Windows is relatively flexible, and there are many ways to accomplish an operation. The following are the actions I use when using git, for reference only. It is not very complete and will be constantly updated later. If you have a good method, you can also modify it and learn together.

1. Tools to be used on windows system

Git-2.8.3-64-bit.exeTortoiseGit-2.2.0.0-64bit

Git-2.8.3-64-bit.exe provides an interface similar to Linux, which can use all the same commands as linux

TortoiseGit-2.2.0.0-64bit provides a right-click menu.

2. Upload the public key to gitlab

On the start menu, find the directory where TortoiseGit is installed, and select "PuTTYgen", as shown below:

In the pop-up dialog box, select "generate" to generate the key pair, as shown below:

After clicking "generate", you will start to read the progress bar. During the reading process, keep moving the mouse, and the following interface appears at the end of the reading bar:

Click "Save private key", save the private key to the local computer, copy "Public key", pay attention to the scroll bar, copy the first character to the last character, do not leave behind.

Log in to gitlab and follow the prompts below:

Then click "SSH Keys", paste the "Public key" you just copied in the text box below "Key", click on the space next to it, it will automatically generate a "Title", and then click "Add key" so that the upload is complete.

3. Create a project

Log in to gitlab, click "New project" in the Dashbord interface, enter the contents of "Project owner" and "Project name" on the jump page, and select "visibility level" as "Private", otherwise it may cause creation failure, as shown below:

After creation, the ssh url of the project will be generated. Anywhere on the local computer, use "git clone" of the right-click menu, pop up a dialog box, paste a "project" ssh URL in URL, click OK, and then clone the remote warehouse locally, as shown below:

After cloning, you need to configure your user name and email address. Use the right-click menu "Tortoisegit-settings". In the pop-up dialog box, set "git" and "remote" respectively, as shown below:

After this setting, there is no need to enter a password for pull and push operations in project.

4. Obtain update "Tortoisegit-pull" from remote warehouse

Before each modification of the file and before commit, it is recommended that you perform a pull operation to get remote updates to prevent commit from colliding with other people's changes later.

5. Submit updates to the remote warehouse

There are two steps:

1. Right-click menu: git commit-> "master" each submission needs to enter description information in the pop-up "message" text box. 2. Right-click menu: Tortoisegit-push

In fact, after the implementation of git commit, there will be a prompt for the operation of push, you can push through this dialog box, as shown in the following figure. You can also submit via "Tortoisegit-push".

6. Check the logs: "Tortoisegit-showlog" and "Tortoisegit-show reflog"

Show log: view all commit history show reflog: view all operation history, including checkout, commit and other operations.

7. Version fallback

Return to a previous commit: open show log, select the commit you want to roll back, right-click, and select "reset master to this version". In the pop-up dialog box, select the fallback commit id and reset type, as shown below:

8. Undo the changes to the file

After making major changes to the file, you can forget where it has been modified. You can use the right-click menu "Tortoisegit-check for modifications" to view it. In the pop-up window, record the modified file. Right-click "show changes as unified diff" in the file you want to view, and see the following figure:

Use the "revert" below to undo changes to the file.

9. Create, switch, merge and delete branches

Create a branch: use the right-click menu "Tortoisegit-create branch", fill in the branch name and click "OK" to complete the creation of the branch, as shown below:

Switch branches: use the right-click menu "Tortoisegit-switch/checkout", select which branch you want to switch to, and click "OK" to complete the branch switching, as shown in the following figure:

Switch branches at a commit: use the right-click menu "Tortoisegit-showlog" to view all the commit, right-click at the commit where you want to switch branches, and select "switch/checkout to this version", as shown below:

Of course, you can also create branches here.

Merge branches: using the right-click menu "Tortoisegit-merge", you can merge a branch into the current branch, as shown below:

This merges the dev branch into the master branch.

Delete branches: first view all branches, as shown in the figure above, and then select the branches to delete.

Resolve the merge conflict: see the figure below, when there is a conflict when merging, you can directly use "resolve" to merge the conflicting files and keep the changes of the two branches. Usually find conflicting files, modify them and then merge them.

The following picture shows the file where the conflict occurred. Git marks the conflict with ">" and modifies it according to the actual situation.

After the modification, first use the right-click menu "Tortoisegit-Resolve" to merge conflicts, and then commit. Of course, you can also use "Tortoisegit-Abort Merge" to undo this branch merge operation. These two commands can only be seen when there is a merge conflict!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report