-
1. Pierwsze kroki
- 1.1 Wprowadzenie do kontroli wersji
- 1.2 Krótka historia Git
- 1.3 Podstawy Git
- 1.4 Linia poleceń
- 1.5 Instalacja Git
- 1.6 Wstępna konfiguracja Git
- 1.7 Uzyskiwanie pomocy
- 1.8 Podsumowanie
-
2. Podstawy Gita
- 2.1 Pierwsze repozytorium Gita
- 2.2 Rejestrowanie zmian w repozytorium
- 2.3 Podgląd historii rewizji
- 2.4 Cofanie zmian
- 2.5 Praca ze zdalnym repozytorium
- 2.6 Tagowanie
- 2.7 Aliasy
- 2.8 Podsumowanie
-
3. Gałęzie Gita
- 3.1 Czym jest gałąź
- 3.2 Podstawy rozgałęziania i scalania
- 3.3 Zarządzanie gałęziami
- 3.4 Sposoby pracy z gałęziami
- 3.5 Gałęzie zdalne
- 3.6 Zmiana bazy
- 3.7 Podsumowanie
-
4. Git na serwerze
- 4.1 Protokoły
- 4.2 Uruchomienie Git na serwerze
- 4.3 Generowanie Twojego publicznego klucza SSH
- 4.4 Konfigurowanie serwera
- 4.5 Git Daemon
- 4.6 Smart HTTP
- 4.7 GitWeb
- 4.8 GitLab
- 4.9 Inne opcje hostowania przez podmioty zewnętrzne
- 4.10 Podsumowanie
-
5. Rozproszony Git
-
6. GitHub
-
7. Narzędzia Gita
- 7.1 Wskazywanie rewizji
- 7.2 Interaktywne używanie przechowali
- 7.3 Schowek i czyszczenie
- 7.4 Signing Your Work
- 7.5 Searching
- 7.6 Przepisywanie historii
- 7.7 Reset Demystified
- 7.8 Advanced Merging
- 7.9 Rerere
- 7.10 Debugowanie z Gitem
- 7.11 Moduły zależne
- 7.12 Bundling
- 7.13 Replace
- 7.14 Credential Storage
- 7.15 Podsumowanie
-
8. Dostosowywanie Gita
- 8.1 Konfiguracja Gita
- 8.2 Git Attributes
- 8.3 Git Hooks
- 8.4 An Example Git-Enforced Policy
- 8.5 Summary
-
9. Git i inne systemy
- 9.1 Git jako klient
- 9.2 Migracja do Gita
- 9.3 Podsumowanie
-
10. Mechanizmy wewnętrzne w Git
- 10.1 Komendy typu plumbing i porcelain
- 10.2 Obiekty Gita
- 10.3 Referencje w Git
- 10.4 Spakowane pliki (packfiles)
- 10.5 Refspec
- 10.6 Protokoły transferu
- 10.7 Konserwacja i odzyskiwanie danych
- 10.8 Environment Variables
- 10.9 Podsumowanie
-
A1. Appendix A: Git in Other Environments
- A1.1 Graphical Interfaces
- A1.2 Git in Visual Studio
- A1.3 Git in Eclipse
- A1.4 Git in Bash
- A1.5 Git in Zsh
- A1.6 Git in Powershell
- A1.7 Summary
-
A2. Appendix B: Embedding Git in your Applications
- A2.1 Command-line Git
- A2.2 Libgit2
- A2.3 JGit
-
A3. Appendix C: Git Commands
- A3.1 Setup and Config
- A3.2 Getting and Creating Projects
- A3.3 Basic Snapshotting
- A3.4 Branching and Merging
- A3.5 Sharing and Updating Projects
- A3.6 Inspection and Comparison
- A3.7 Debugging
- A3.8 Patching
- A3.9 Email
- A3.10 External Systems
- A3.11 Administration
- A3.12 Plumbing Commands
A3.3 Appendix C: Git Commands - Basic Snapshotting
Basic Snapshotting
For the basic workflow of staging content and committing it to your history, there are only a few basic commands.
git add
The git add
command adds content from the working directory into the staging area (or “index”) for the next commit. When the git commit
command is run, by default it only looks at this staging area, so git add
is used to craft what exactly you would like your next commit snapshot to look like.
This command is an incredibly important command in Git and is mentioned or used dozens of times in this book. We’ll quickly cover some of the unique uses that can be found.
We first introduce and explain git add
in detail in Śledzenie nowych plików.
We mention how to use it to resolve merge conflicts in Podstawowe konflikty scalania.
We go over using it to interactively stage only specific parts of a modified file in Interaktywne używanie przechowali.
Finally, we emulate it at a low level in Obiekty drzew, so you can get an idea of what it’s doing behind the scenes.
git status
The git status
command will show you the different states of files in your working directory and staging area. Which files are modified and unstaged and which are staged but not yet committed. In its normal form, it also will show you some basic hints on how to move files between these stages.
We first cover status
in Sprawdzanie stanu twoich plików, both in its basic and simplified forms. While we use it throughout the book, pretty much everything you can do with the git status
command is covered there.
git diff
The git diff
command is used when you want to see differences between any two trees. This could be the difference between your working environment and your staging area (git diff
by itself), between your staging area and your last commit (git diff --staged
), or between two commits (git diff master branchB
).
We first look at the basic uses of git diff
in Podgląd zmian w poczekalni i poza nią, where we show how to see what changes are staged and which are not yet staged.
We use it to look for possible whitespace issues before committing with the --check
option in Wskazówki wgrywania zmian.
We see how to check the differences between branches more effectively with the git diff A...B
syntax in Ustalenie co zostało wprowadzone.
We use it to filter out whitespace differences with -b
and how to compare different stages of conflicted files with --theirs
, --ours
and --base
in Advanced Merging.
Finally, we use it to effectively compare submodule changes with --submodule
in Rozpoczęcie prac z modułami zależnymi.
git difftool
The git difftool
command simply launches an external tool to show you the difference between two trees in case you want to use something other than the built in git diff
command.
We only briefly mention this in Podgląd zmian w poczekalni i poza nią.
git commit
The git commit
command takes all the file contents that have been staged with git add
and records a new permanent snapshot in the database and then moves the branch pointer on the current branch up to it.
We first cover the basics of committing in Zatwierdzanie zmian. There we also demonstrate how to use the -a
flag to skip the git add
step in daily workflows and how to use the -m
flag to pass a commit message in on the command line instead of firing up an editor.
In Cofanie zmian we cover using the --amend
option to redo the most recent commit.
In Czym jest gałąź, we go into much more detail about what git commit
does and why it does it like that.
We looked at how to sign commits cryptographically with the -S
flag in Signing Commits.
Finally, we take a look at what the git commit
command does in the background and how it’s actually implemented in Obiekty commit.
git reset
The git reset
command is primarily used to undo things, as you can possibly tell by the verb. It moves around the HEAD
pointer and optionally changes the index
or staging area and can also optionally change the working directory if you use --hard
. This final option makes it possible for this command to lose your work if used incorrectly, so make sure you understand it before using it.
We first effectively cover the simplest use of git reset
in Usuwanie pliku z poczekalni, where we use it to unstage a file we had run git add
on.
We then cover it in quite some detail in Reset Demystified, which is entirely devoted to explaining this command.
We use git reset --hard
to abort a merge in Aborting a Merge, where we also use git merge --abort
, which is a bit of a wrapper for the git reset
command.
git rm
The git rm
command is used to remove files from the staging area and working directory for Git. It is similar to git add
in that it stages a removal of a file for the next commit.
We cover the git rm
command in some detail in Usuwanie plików, including recursively removing files and only removing files from the staging area but leaving them in the working directory with --cached
.
The only other differing use of git rm
in the book is in Usuwanie obiektów where we briefly use and explain the --ignore-unmatch
when running git filter-branch
, which simply makes it not error out when the file we are trying to remove doesn’t exist. This can be useful for scripting purposes.
git mv
The git mv
command is a thin convenience command to move a file and then run git add
on the new file and git rm
on the old file.
We only briefly mention this command in Zmiana nazw plików.
git clean
The git clean
command is used to remove unwanted files from your working directory. This could include removing temporary build artifacts or merge conflict files.
We cover many of the options and scenarios in which you might used the clean command in Cleaning your Working Directory.