Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Aphorismen
Applications
Business Economics & Admin.
My Computers
Cooking
Devices
Folders
Food
Hardware
Infos
Software Development
Sports
Operation Instructions
Todos
Test
Help
Glossary
Community portal
adaptions
Sidebar anpassen
Wiki RB4
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Git
(section)
Page
Discussion
English
Read
Edit
View history
Toolbox
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Concepts== Git is a '''Distributed Version Control Systems''' (DVCS). Clients don’t just check out the latest snapshot of the files, they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data. A '''Git Version (commit object)''' (short:commit) represents a version of all files tracked in the repository at the time the commit was created: [[File:GitVersions1.JPG|600px]] For Git a version history is a stream of snapshots of the complete project. Therefore the local repository contains the complete history of a project. A remote repository on a server typically does not require a working tree. A Git repository without a working tree is called a '''bare repository'''. In a DVCS the elemental concept is a '''change set''', it is merely a change to a set of files and a pointer to the previous change set. For identification the change set includes a pointer to the previous change set and which is hashed then. A changeset is merely a change to a set of files. Git changesets are identified by an SHA-1 hash, which is a 40 character checksum of the content of a file. The tip of the current local branch is referred to as '''[[Git#Head|HEAD]]'''. Git focus on content (files), therefore empty '''directories''' are not in a repository (unless you put an .gitignore in the directory, then it is created). '''Origin''' is an alias on your system for a particular remote repository and sometimes a shorthand name for the remote repository that a project was originally cloned from. More precisely, it is used instead of that original repository's URL - and thereby makes referencing much easier (see [[Git#Show_remote_Repository|here]]). For a graphical description see [https://git-scm.com/book/de/v1/Git-Branching-Was-ist-ein-Branch%3F here]. . ===File States=== Each file in the working directory can have one the following states: * '''Untracked''' (unversioned) means the file is not tracked by the Git repository. This means that the file never staged nor committed. * '''Tracked''' (committed) means that the data is safely stored in your local database. The tracked files can be: ** '''new file''': new file being staged by <code>git add</code> for the first time for this file ** '''Unmodified''': the file was commited and is unchanged ** '''Modified''' (unstaged): the files was edited (but not staged) ** '''Staged''' (indexed): a modified file is marked in its current version to go into your next commit snapshot by <code>git add</code> ===Operations=== ====Cloning==== '''Cloning''' is the process of copying an existing Git repository via the Git tooling. ====Checkout==== A '''checkout''' copies a local branch (version of the last commit of this branch) into the working directory and set the [[Git#Head|HEAD]] accordingly. This can include deletion of files or directories which are part of the current branch but not of the branch to be checkout (commands see [[Git#Checkout_a_branch|here]]). ====Fetch==== The git '''fetch''' command downloads commits, files, and refs from a remote repository into your local repo (it does not merge anything with local changes). Fetching is what you do when you want to see what everybody else has been working on (see [[Git#Fetch_everything_from_Remote|here]]). ====Merge==== There are different methods to merge: * fast-forward (pointer just been moved forward) * recursive strategy (creates a merge commit) In case that the branches to merge are changed in different directions the merge will result in a new '''merge commit'''. ====Pull==== A git '''pull''' does a git '''fetch''' followed by a git '''merge''' (a fetch does not change the working directory). ====Push==== '''Pushing''' means sending a new version of the local repository to a remote repositories. [[File:GitProcess_1.JPG|400px]] [[File:nWYnQ.png|400px]] ====Stash==== Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch). ===Repository=== A '''Repository''' is essentially a folder on the local hard disk which contains the working directory and the metadata folder (git directory). In most cases there is one repository per project but it is possible to have multiple projects in one repo (monorepo approach). The '''Git directory (.git)''' is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when cloning a repository from another computer. [[File:GitStructure.JPG|400px]] ===Branches=== Branching is the way to work on different versions of a repository at one time. By default your repository has one branch named '''master'''. Branches are something like a pointer to a element of a version chain. [[File:GitHubBranchButton.JPG]] '''Tracking Branches''' (external branches) are '''local branches''' with a direct link to a remote branch. They resemble bookmarks to the branches in a remote repositories of the last connection and written as <REPOSITORY>/<BRANCHNAME>. If a tracking branch is selected, git knows in case of a <code>git push|pull</code> which server and repository to be used. The remote branch which is referenced is called '''upstream branch'''. Tracking Branches are updated only by in case of network operations of git. '''Remote Branches''' are like any other branch, but read-only. To use the remote changes the remote branch has to be merged into the local branch (that is what <code>git pull</code> does as a shortcut for <code>git fetch</code> followed by <code>git merge</code>. ====Directories==== Local Branches in subdirectories below: .git/refs/heads Remote Branches in subdirectories below: .git/refs/remote ===Working Directory/Tree=== The '''working directory''' is the directory used to modify files for the next commit (it seems that it is sometimes also called '''working tree'''). By default it is located one level above the [[#Repository|.git directory]]. It is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. It corresponds to a checkout of one version of the repository with potential changes done by the user. The user can change the files in the working tree by modifying existing files and by creating and removing files. \<Repository>\ // Working Directory \.git\ // Git Directory ===Staging Area=== The '''staging area''' or '''index''' is a file (.git/index) filled by <code>git add</code>, generally contained in your Git directory, that stores information about what will go into your next commit. ===Head=== The '''HEAD''' points to head of current local branch. ===[[GitHub|GitHub]]=== Although it is not necessary it is very common to use git together with GitHub. ===Tag=== A '''tag''' points to a commit which uniquely identifies a version of the Git repository. The benefit of tags is to mark the repository for a specific reason, e.g., with a release. ===Ignore=== Git can be configured to '''ignore''' certain files and directories for repository operations. This is configured via one or several .gitignore files. Typically, this file is located at the root of your Git repository but it can also be located in sub-directories. In the second case the defined rules are only valid for the sub-directory and below. <code>.gitignore</code> should be part of the versioned files. To add a complete directory create one line with <DIRECTORY_NAME>
Summary:
Please note that all contributions to Wiki RB4 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Uwe Heuer Wiki New:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width