Developing FreeCAD with GitKraken/pl: Difference between revisions

From FreeCAD Documentation
(Created page with "{{Caption|Rebasing local master aktualizuje go tak, aby pasował do zawartości upstream master.}}")
(Created page with "==Gałęzie==")
Line 102: Line 102:
{{Caption|Rebasing local master aktualizuje go tak, aby pasował do zawartości upstream master.}}
{{Caption|Rebasing local master aktualizuje go tak, aby pasował do zawartości upstream master.}}


== Branches ==
<span id="Branches"></span>
==Gałęzie==


Branches are a feature that makes Git powerful compared to other revision systems. Branches aren't complete forks, but rather define snapshots where a version of the code starts diverging from the master branch. Whenever you want to modify the FreeCAD code, first create a branch, then make changes, and then merge your commits back to the master branch. With Git it is simple to create, merge and delete branches when you no longer need them. Please read [https://support.gitkraken.com/working-with-repositories/branching-and-merging Branching and Merging] to understand more about this process in GitKraken.
Branches are a feature that makes Git powerful compared to other revision systems. Branches aren't complete forks, but rather define snapshots where a version of the code starts diverging from the master branch. Whenever you want to modify the FreeCAD code, first create a branch, then make changes, and then merge your commits back to the master branch. With Git it is simple to create, merge and delete branches when you no longer need them. Please read [https://support.gitkraken.com/working-with-repositories/branching-and-merging Branching and Merging] to understand more about this process in GitKraken.

Revision as of 11:20, 12 November 2023

Other languages:

Przedmowa

FreeCAD używa Git do zarządzania swoim kodem źródłowym. Niniejszy dokument stanowi pobieżne wprowadzenie do GitKraken, graficznego interfejsu użytkownika Git. GitKraken jest zastrzeżonym oprogramowaniem, które jest bezpłatne do użytku niekomercyjnego. Nie potrzebujesz GitKrakena do tworzenia kodu dla FreeCAD, ale wielu programistów lubi go i uważa za przydatny do zarządzania ich rozwojem. FreeCAD nie popiera GitKraken, ale mamy nadzieję, że przewodnik taki jak ten pokaże użytkownikom, jak łatwo jest skonfigurować środowisko programistyczne i zachęci więcej osób do wniesienia wkładu.

Więcej informacji na temat ogólnego korzystania z Git z linii poleceń można znaleźć na stronie Zarządzanie kodem źródłowym oraz w książce online Pro Git. Aby skompilować FreeCAD zobacz stronę Kompilacja.

Wprowadzenie

Git to potężny system kontroli wersji powszechnie używany do śledzenia rozwoju kodu komputerowego. Mimo że jest to złożony system, zwykle potrzebne są tylko podstawowe informacje na temat jego działania i znajomość kilku poleceń terminala. Graficzny interfejs użytkownika (GUI) ułatwia naukę. GitKraken to zastrzeżony program, który jest darmowy do użytku niekomercyjnego i działa na platformie Electron, co oznacza, że jest wieloplatformowy i może być używany tak samo w systemach Linux, MacOS i Windows.

Konfiguracja Git development

Istnieją różne sposoby pobrania GitKraken w zależności od systemu operacyjnego. W dystrybucjach Linuksa czasami można go pobrać z menedżera pakietów.

  1. Pobierz GitKraken.
  2. W przeglądarce internetowej przejdź do strony: https://github.com/FreeCAD/FreeCAD.
  3. Kiknij na Fork. Spowoduje to sklonowanie repozytorium FreeCAD/FreeCAD do własnego konta. Innymi słowy, adres URL dostępu do forka będzie następujący:
    https://github.com/GITHUBUSERNAME/FreeCAD.git
    
  4. Otwórz GitKraken, przejdź do menu File → Clone Repo, kolejnie wprowadź adres.
  5. GitKraken wykona teraz operację git clone na twoim osobistym repozytorium. Zapoznaj się z różnicą między zdalnym repozytorium origin vs. upstream. Essentially, Twój fork FreeCAD jest repozytorium origin, podczas gdy oficjalne repozytorium FreeCAD jest upstream. Teraz musisz odpowiednio ustawić upstream.
  6. Znajdź pasek boczny w Gitkraken. Znajduje się tam sekcja Lokalna i Zdalna. Sekcja Local odnosi się do lokalnych oddziałów. Sekcja Remote odnosi się do zdalnych repozytoriów i ich gałęzi. Dodajmy repozytorium FreeCAD jako zdalne. W sekcji Remote kliknij przycisk +. ( jak pokazano na poniższym obrazku)
  7. Otworzy się okno dialogowe Add Remote. Kliknij symbol Github (1). W polu Github repo (2) znajdź FreeCAD/FreeCAD i kliknij na niego. W polu Name wpisz upstream. Następnie kliknij przycisk Add Button.
  8. Okno dialogowe zostanie zamknięte i nastąpi powrót do głównego interfejsu GitKrakena. Tym razem znajdź sekcję Local na pasku bocznym. Kliknij dwukrotnie gałąź master, aby się do niej przełączyć. W wierszu poleceń jest to równoważne
    git checkout master
    
  9. Kliknij ikonę "Push" w prawym górnym rogu interfejsu. Spowoduje to wypchnięcie Local master do Remote origin master

Interfejs GitKraken

Więcej informacji można znaleźć w podręczniku GitKraken Przewodnik dla początkujących.

Local wskazuje komputer lokalny
Local master Lokalna gałąź głównej gałęzi FreeCAD, oznaczona niebieską linią na zrzucie ekranu.

Element jest podświetlony na zielono, co oznacza, że gałąź jest obecnie aktywna (git checkout).

Local <branch-name> Wszelkie inne gałęzie na lokalnym komputerze. Na zrzucie ekranu widać gałęzie o nazwach editor_fixes i editor_fixes_typos.
Remote wskazuje zdalne repozytorium, na przykład w serwisie GitHub
Remote upstream Oficjalne repozytorium FreeCAD https://github.com/FreeCAD/FreeCAD, oznaczone zieloną linią na zrzucie ekranu.
Remote origin Twój osobisty fork FreeCAD, https://github.com/YourGitHubUsername/FreeCAD, oznaczony czerwoną linią na zrzucie ekranu.

Interfejs GitKraken pokazujący trzy lokalne gałęzie, w tym lokalną master, oraz zdalne repozytoria origin i upstream, z których każde ma gałęzie master i release.

Na obrazku zdalne gałęzie Local master i Remote origin master są trzy commity za Remote upstream master, czyli oficjalnym kodem źródłowym FreeCAD. Wskazują na to ikony znajdujące się trzy kroki za łańcuchem, który reprezentuje historię zatwierdzeń gałęzi głównej. Zobacz Zmiana bazy, aby zaktualizować gałęzie, które są w tyle.

Rebasing

  • Sprawdź gałąź Local master, klikając na nią dwukrotnie (git checkout master).
  • Przesuń kursor myszy do ostatniego zatwierdzenia upstream, kliknij prawym przyciskiem myszy i wybierz Rebase master onto upstream/master (git pull upstream master).
  • Teraz naciśnij przycisk Push (git push origin master). Spowoduje to wypchnięcie z Local master do Remote origin master.

Rebasing local master aktualizuje go tak, aby pasował do zawartości upstream master.

Gałęzie

Branches are a feature that makes Git powerful compared to other revision systems. Branches aren't complete forks, but rather define snapshots where a version of the code starts diverging from the master branch. Whenever you want to modify the FreeCAD code, first create a branch, then make changes, and then merge your commits back to the master branch. With Git it is simple to create, merge and delete branches when you no longer need them. Please read Branching and Merging to understand more about this process in GitKraken.

  1. Make sure you currently have the master branch active (double click on it, git checkout master). In GitKraken the Local master branch should be highlighted in green.
  2. Click the Branch button to create a new branch and enter its new name (git checkout -b new-name-of-your-branch).

Making pull requests

Pull requests (PRs) are necessary to merge the code in a branch in your local repository with the code in the upstream repository. To summarize the process, once you've modified your branch, you need to push it to your GitHub fork (origin, https://github.com/GITHUBUSERNAME/FreeCAD.git), and from there make a pull request to upstream. GitKraken saves you some clicks to easily create pull requests instead of using GitHub's interface.

Steps in GitKraken:

  • Find you local branch on the interface and make sure it's active (double click on it).
  • Right click the branch name and find the option to Push <your-branch-name> and start a pull request.
GitKraken will open a dialog that asks you to confirm the repository which your branch will use to pull and push. It will then push your local branch to that remote repository.

  • GitKraken will ask you what you want to call the remote branch. The default name is the same name that the branch has locally in your computer.

  • GitKraken then opens up another dialog asking the repositories and branches to merge, and the direction (from and to).
You normally want to merge from the remote origin <your-branch-name> (GITHUBUSERNAME/FreeCAD) to the remote upstream master branch (FreeCAD/FreeCAD). Be sure to enter a good title for the pull request, and write a more descriptive paragraph if your changes are significant. Consult the official documentation of GitKraken for more information.

Resolving merge conflicts

GitKraken has a special merge conflict tool that is only accessible in the GitKraken Pro version. However, there are workarounds to use external tools for merging.

Squashing commits

As a revision control system Git encourages making many commits to keep track of your changes; however, if you have too many small changes the commit history may look a bit messy. Squashing is condensing various commits into only one commit. From the GitKraken manual, squashing is available for commits that meet the following requirements:

  • You need to select at least two commits to squash.
  • The youngest commit, by commit date, is also the current HEAD commit.
  • Genealogically consecutive.
  • Chronologically consecutive.
  • The oldest commit in the list has a parent.

If all these conditions are met, the Squash option appears when you right click the commit node. See Squash.gif

Following other FreeCAD repositories

You can use GitKraken to follow the personal FreeCAD forks of other developers; in this way you can see how they write code and commit changes to their own branches before they submit pull requests to the upstream FreeCAD/FreeCAD repository.

  1. In the left side panel next to the Remote category, press the + sign.
  2. A dialogue will come up to enter the name of the repository that you want to add. Recommended remotes are from the main FreeCAD developers and known contributors: wmayer, yorikvanhavre, ickby, sliptonic, kkremitzki, etc.
  3. Press Add Remote.

Now whenever new commits are made, or branches are rebased, by the authors of those repositories, you will see their commit history in a graphical way.

Related