WebTools Git/ru: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
<languages/>

<div class="mw-translate-fuzzy">
{{GuiCommand/ru
{{GuiCommand/ru
|Name=Arch Git‏‎
|Name=WebTools Git‏‎
|Name/ru=Arch Git‏‎
|Name/ru=Arch Git‏‎
|Workbenches=[[Arch Module/ru|Arch]]
|MenuLocation=Архитектура → Утилиты → Commit with Git
|MenuLocation=Архитектура → Утилиты → Commit with Git
|Workbenches=[[Arch_Workbench/ru|Arch]]
|Shortcut=
|Shortcut=
‏‎|SeeAlso=
‏‎|SeeAlso=
}}
}}
</div>
<div id="itsfree" style="text-align:left;color:black;background:#f6f6f6;margin:1em 7em;padding:0.5em 2em;border:2px solid #a7d7f9;">


'''Note:''' Starting from FreeCAD v0.17, this tool has been removed from the Arch Workbench and is now part of the external Webtools Workbench that you can install via menu Tools → Addons Manager.</div>
{{VeryImportantMessage|Starting from FreeCAD v0.17, this tool has been removed from the Arch Workbench and is now part of the external [[WebTools Workbench]] that you can install via menu Tools → [[Image:AddonManager.svg|24px]] [[Std_AddonMgr|Addon manager]].
}}
==Description==


<span id="Description"></span>
This command allows to manage the current document with [https://en.wikipedia.org/wiki/Git_%28software%29 GIT]. GIT is a powerful file version control system, which can manage different versions of files and keep track of the changes.
==Описание==


Этот инструмент позволяет вам управлять документом используя [https://ru.wikipedia.org/wiki/Git_%28software%29 Git]. Git является мощной системой контроля версий, которая может управлять разными версиями и отслеживать изменения
Git is a complex tool, consider learning the basics of it before using this tool, to avoid wrong operations that can cause data loss. An abundant literature about GIT is available and easy to find on the internet.


Git довольно сложный инструмент, вам лучше изучить его основы, перед использованием этого инструмента, чтобы избежать потерь данных. Всеобъемлющая литература о Git легко находится в интернете.
Current limitations:


'''Необходимое условие:''' Чтобы иметь возможность пользоваться данным инструментом, пакет [https://github.com/gitpython-developers/GitPython gitpython] должен быть установлен в вашей системе. В большинстве linux дистрибутивов, gitpython есть в стандартном репозитории под названием ''gitpython'' или ''python-git''.
* The tool cannot create new repositories yet. You must have an existing local repository already created (FreeCAD will check if the current document file is inside a Git repository)
* The tool cannot change or create branches. You must do that manually with standard Git tools.

'''Note:''' To be able to use this command, the [https://github.com/gitpython-developers/GitPython gitpython] package must be installed on your system. On most linux distributions, gitpython is available from the standard software repositories as ''gitpython'' or ''python-git''.


<span id="Usage"></span>
==How to use==
==Применение==


# Make sure the [[Report_view|Report view]] is open since Git messages will be printed there.
# Save the current active document
# Make sure the saved file is inside an existing git repository
# Save the current active document making sure the saved file is inside an existing git repository. It can be in a subdirectory.
# Select menu Arch -> Utilities -> {{KEY|[[Image:Arch CommitGit.png|16px]] [[Arch Git|Git]]}}
# Select menu {{MenuCommand|Web Tools [[Image:WebTools_Git.svg|16px]] [[WebTools_Git|Git]]}}
# This opens up a [[Task_panel|Task panel]] in the [[Combo_view|Combo view]].


==Options==
==Options==


[[Image:Arch Git panel.jpg|right]]
[[Image:Arch Git panel.jpg|thumb|Tasks tab showing Git interface]]


* The '''Log''' button will pop up a dialog showing the most recent log entries. The output corresponds to {{Incode|git log}}.
* Make sure the '''Report Window''' is open since Git messages will be printed there.
* The Git tool will only open if the current file is saved inside a Git repository. It can be in a subdirectory.
* The '''Refresh''' button will re-scan the repository for changed files. After saving your work you have to do a manual refresh.
* The '''Log''' button will pop up a dialog showing the most recent log entries.
* The '''Diff''' button will show the differences between the current version of a selected file and the most recent version stored in the repository. The output corresponds to {{Incode|git diff}}.
** By default a binary diff is made, you have to set up the {{Incode|fcinfo}} tool for textual diffing.
* The '''Refresh''' button will re-scan the repository for changed files.
* The '''Diff''' button will show the differences between the current version of a selected file and the previous version stored in the repository.
* The '''Select all''' button will select all files to be committed.
* The '''Select all''' button will select all files to be committed.
* The '''Commit''' button will commit the selected files. Be sure to write a commit message that describes the changes you are committing.
* The '''Commit''' button will commit the selected files. Be sure to write a commit message that describes the changes you are committing.
Line 44: Line 45:
* The '''Push''' button will '''upload''' your latest commit(s) to the selected remote.
* The '''Push''' button will '''upload''' your latest commit(s) to the selected remote.


==Limitations==
==Enabling human-readable diff for FCStd files==


* The tool cannot create new repositories yet. You must have an existing local repository already created. (FreeCAD will check if the current document file is inside a Git repository.)
FreeCAD's [[Fcstd file format]] is a zip-based binary format, for which Git cannot produce proper diffs. This means that you cannot see what has changed between one version and another, and also that each new version stored in the Git repository is a full copy of the file.
* The tool cannot change or create branches. You must do that manually with standard Git tools.

==Enabling human-readable diffs for FCStd files with the fcinfo utility==

FreeCAD's [[File_Format_FCStd|FCStd file format]] is a zip-based binary format, for which Git cannot produce proper diffs. This means that you cannot see what has changed between one version and another, and also that each new version stored in the Git repository is a full copy of the file.


Although the second problem currently has no solution, the first one can be solved with a little tool available from the FreeCAD source code, called [https://github.com/FreeCAD/FreeCAD/blob/master/src/Tools/fcinfo fcinfo]. Git can be told to use the fcinfo utility to print a human-friendly report of a FCStd file, and, when asked to produce a diff between two FCStd files, will produce a diff between the two fcinfo reports instead. Please note that this is only visual feedback, a full copy of the file will still be stored internally.
Although the second problem currently has no solution, the first one can be solved with a little tool available from the FreeCAD source code, called [https://github.com/FreeCAD/FreeCAD/blob/master/src/Tools/fcinfo fcinfo]. Git can be told to use the fcinfo utility to print a human-friendly report of a FCStd file, and, when asked to produce a diff between two FCStd files, will produce a diff between the two fcinfo reports instead. Please note that this is only visual feedback, a full copy of the file will still be stored internally.
Line 103: Line 109:
To enable the use of fcinfo (Linux and Mac only - TODO: add Windows instructions)
To enable the use of fcinfo (Linux and Mac only - TODO: add Windows instructions)


# Save the fcinfo file somewhere in your system path
=== Using fcinfo on a single Git repository ===

# Make it executalbe
These are the steps to enable the use of fcinfo tool in a repository basis.
# Create a .gitattributes file in your Git repository
* Save the fcinfo file somewhere in your system path.
# Add the following line in it:
: Note: Since 2023-12-09, on Arch Linux systems the {{Incode|fcinfo}} script is included on {{Incode|freecad}} package, [https://gitlab.archlinux.org/archlinux/packaging/packages/freecad/-/commit/4419bfbfdb670abebd7f2e6ed93194e819781f7d patch here].
*.FCStd diff=fcinfo
* Make it executable.
: Note: Since 2023-12-09, on Arch Linux systems the {{Incode|fcinfo}} is available at {{Incode|/usr/bin/fcinfo}}.
* Create a {{Incode|.gitattributes}} file in your Git repository and add the following line in it:

: {{Code|lang=text|code=
*.FCStd diff=fcinfo
}}

* Add the following lines to the {{Incode|.gitconfig}} file in your home directory:

: {{Code|lang=text|code=
[diff "fcinfo"]
textconv = /path/to/fcinfo
}}

* Alternatively, if you want to invoke fcinfo with arguments (e.g., {{Incode|--gui}}) use [https://stackoverflow.com/questions/55601430/how-to-pass-a-filename-argument-gitconfig-diff-textconv this approach]:

: {{Code|lang=text|code=
[diff "fcinfo"]
textconv = sh -c '/path/to/fcinfo --gui "$0"'XD
}}

Note that if you are working in a collaborative project you may want to include the fcinfo tool in your repository, in that case the path is relative to your Git repository root directory.

=== Enabling fcinfo globally ===

If you are working on many projects that need fcinfo tool you can enable it globally for your user.
* Create a {{Incode|$HOME/.config/git/attributes}} file and add the following line on it:

: {{Code|lang=text|code=
*.FCStd diff=fcinfo
}}

* Add the following lines to the {{Incode|$HOME/.config/git/config}} file:
** It's equivalent command is {{Incode|git config --global diff.fcinfo.textconv "/path/to/fcinfo"}}.
** Arch Linux users using {{Incode|freecad}} package can use {{Incode|textconv = fcinfo}} since it's already installed on their system.

: {{Code|lang=text|code=
[diff "fcinfo"]
textconv = /path/to/fcinfo
}}

Note that any configuration made in a repository basis overrides global configurations.

Latest revision as of 10:45, 20 February 2024

Other languages:

Arch Git‏‎

Системное название
WebTools Git‏‎
Расположение в меню
Архитектура → Утилиты → Commit with Git
Верстаки
Arch
Быстрые клавиши
‏‎
Представлено в версии
-
См. также
Нет

Starting from FreeCAD v0.17, this tool has been removed from the Arch Workbench and is now part of the external WebTools Workbench that you can install via menu Tools → Addon manager.

Описание

Этот инструмент позволяет вам управлять документом используя Git. Git является мощной системой контроля версий, которая может управлять разными версиями и отслеживать изменения

Git довольно сложный инструмент, вам лучше изучить его основы, перед использованием этого инструмента, чтобы избежать потерь данных. Всеобъемлющая литература о Git легко находится в интернете.

Необходимое условие: Чтобы иметь возможность пользоваться данным инструментом, пакет gitpython должен быть установлен в вашей системе. В большинстве linux дистрибутивов, gitpython есть в стандартном репозитории под названием gitpython или python-git.

Применение

  1. Make sure the Report view is open since Git messages will be printed there.
  2. Save the current active document making sure the saved file is inside an existing git repository. It can be in a subdirectory.
  3. Select menu Web Tools → Git
  4. This opens up a Task panel in the Combo view.

Options

Tasks tab showing Git interface
  • The Log button will pop up a dialog showing the most recent log entries. The output corresponds to git log.
  • The Refresh button will re-scan the repository for changed files. After saving your work you have to do a manual refresh.
  • The Diff button will show the differences between the current version of a selected file and the most recent version stored in the repository. The output corresponds to git diff.
    • By default a binary diff is made, you have to set up the fcinfo tool for textual diffing.
  • The Select all button will select all files to be committed.
  • The Commit button will commit the selected files. Be sure to write a commit message that describes the changes you are committing.
  • The Pull button will download any new changes to the repository from the selected remote. If the file currently opened in FreeCAD is being modified by a pull, a warning message will inform you so you can either save the file again or save it elsewhere.
  • The Push button will upload your latest commit(s) to the selected remote.

Limitations

  • The tool cannot create new repositories yet. You must have an existing local repository already created. (FreeCAD will check if the current document file is inside a Git repository.)
  • The tool cannot change or create branches. You must do that manually with standard Git tools.

Enabling human-readable diffs for FCStd files with the fcinfo utility

FreeCAD's FCStd file format is a zip-based binary format, for which Git cannot produce proper diffs. This means that you cannot see what has changed between one version and another, and also that each new version stored in the Git repository is a full copy of the file.

Although the second problem currently has no solution, the first one can be solved with a little tool available from the FreeCAD source code, called fcinfo. Git can be told to use the fcinfo utility to print a human-friendly report of a FCStd file, and, when asked to produce a diff between two FCStd files, will produce a diff between the two fcinfo reports instead. Please note that this is only visual feedback, a full copy of the file will still be stored internally.

Example of a diff produced with fcinfo:

diff --git a/testhouse.FcStd b/testhouse.FcStd
index 08077b6..985b1d8 100644
--- a/testhouse.FcStd
+++ b/testhouse.FcStd
@@ -1,26 +1,25 @@
-Document: /tmp/43un09_testhouse.FcStd (442K)
-   SHA1: 67c1985a45d93cba57d5bf44490897aba460100d
+Document: /tmp/zfXoDd_testhouse.FcStd (370K)
+   SHA1: db1cb5fca18af7bfdca849028f40550df4d845cb
    Comment : This is a test house to showcase FreeCAD's BIM worflow and IFC export capabilities
    Company : uncreated.net
    CreatedBy : Yorik van Havre
    CreationDate : Fri May  9 12:05:54 2014 
    FileVersion : 1
    Id : 
-   Label : testhouse
-   LastModifiedBy : Yorik van Havre
-   LastModifiedDate : 2016-06-28T17:05:57-03:00
+   Label : testhouse2
+   LastModifiedBy : Yorik van Havre
+   LastModifiedDate : Sat Sep 13 20:46:36 2014
+
    License : CC-BY 3.0
    LicenseURL : http://creativecommons.org/licenses/by/3.0/
-   ProgramVersion : 0.17R7800 (Git)
-   TipName : 
+   ProgramVersion : 0.15R3989 (Git)
    Uid : 67e62d8a-6674-4358-92fe-615443be887a
-   Objects: (231)
+   Objects: (221)
        Annotation : Drawing::FeatureViewAnnotation
        Annotation001 : Drawing::FeatureViewAnnotation
        Annotation002 : Drawing::FeatureViewAnnotation
        Annotation003 : Drawing::FeatureViewAnnotation
-       Annotation004 : Drawing::FeatureViewAnnotation
-       Annotation005 : Drawing::FeatureViewAnnotation
        Array : Part::FeaturePython (9K)
        Box : Part::Box (2K)
        Building : App::DocumentObjectGroupPython
@@ -110,7 +109,7 @@ Document: /tmp/43un09_testhouse.FcStd (442K)
        Floor : App::DocumentObjectGroupPython
        Floor001 : App::DocumentObjectGroupPython
        Floor002 : App::DocumentObjectGroupPython
-       Frame : Part::FeaturePython (89K)

Each FreeCAD file contains a SHA1 checksum number, which will change each time the file is saved, even if no contents was changed. So fcinfo will always print something, no matter of the contents changes.

To enable the use of fcinfo (Linux and Mac only - TODO: add Windows instructions)

Using fcinfo on a single Git repository

These are the steps to enable the use of fcinfo tool in a repository basis.

  • Save the fcinfo file somewhere in your system path.
Note: Since 2023-12-09, on Arch Linux systems the fcinfo script is included on freecad package, patch here.
  • Make it executable.
Note: Since 2023-12-09, on Arch Linux systems the fcinfo is available at /usr/bin/fcinfo.
  • Create a .gitattributes file in your Git repository and add the following line in it:
*.FCStd diff=fcinfo
  • Add the following lines to the .gitconfig file in your home directory:
[diff "fcinfo"]
textconv = /path/to/fcinfo
  • Alternatively, if you want to invoke fcinfo with arguments (e.g., --gui) use this approach:
[diff "fcinfo"]
textconv = sh -c '/path/to/fcinfo --gui "$0"'XD

Note that if you are working in a collaborative project you may want to include the fcinfo tool in your repository, in that case the path is relative to your Git repository root directory.

Enabling fcinfo globally

If you are working on many projects that need fcinfo tool you can enable it globally for your user.

  • Create a $HOME/.config/git/attributes file and add the following line on it:
*.FCStd diff=fcinfo
  • Add the following lines to the $HOME/.config/git/config file:
    • It's equivalent command is git config --global diff.fcinfo.textconv "/path/to/fcinfo".
    • Arch Linux users using freecad package can use {{{1}}} since it's already installed on their system.
[diff "fcinfo"]
textconv = /path/to/fcinfo

Note that any configuration made in a repository basis overrides global configurations.