Table of Contents
11 Basic Usage
We created a test repository to let you check your installation and make your first steps.
1. Get code
Clone
To get the code you need to clone a remote repository:
git clone git@gitlab.com:hampel-soft/open-source/hampelsoft-test.git
Beware: SSH clients use the known_hosts
file to authenticate the server, to check that it isn't connecting to an impersonator. The first time you connect to a new server, you have to acknowledge the authenticity of the server by accepting the ECDSA key fingerprint. Some GUI clients hide the appropriate message, so if you get permission errors, try cloning from the command line.
Pull
If you already cloned a repo, you can pull updates from the remote repository into your local clone:
git pull
This will fetch changes from a remote repository and integrate the changes into the current branch.
Fetch
If you only want to download the changes from the remote repository, but not (yet) update the actual files on your local repo, you can fetch:
git fetch
If you want to update (pull into) a branch other than your local head, you can. For example, you can pull changes from origin/develop
into develop
while working in another branch by using this command:
git fetch origin develop:develop
Git submodule
A submodule is a repository embedded inside another repository. We provide a detailed description and other resources on our Best Practices page on git submodules.
The hampelsoft-test
repository contains the hampelsoft-test-sub
repo as a submodule. After cloning the repository, the submodule directory is empty (as it is uninitialized). The following command pulls the contents of the submodule repository into the local submodule folder:
cd hampelsoft-test git submodule update --init --remote --recursive
2. Work locally
To propose files for version controlling (to make git work with your files) you need to stage the files:
git add README.txt
To actually add new or changed files to the repository, you need to commit them:
git commit -m "first commit"
3. Share with others
To send your changes to the central, remote repository, you need to push your local repository:
git push -u origin master
Be aware that you cannot push to the origin
of our hampelsoft-test
and hampelsoft-test-sub
repositories as you do not have sufficient access rights. Please read up on workflows and the project forking workflow in particular for more information.
4. Case-sensitivity
Git is case-sensitive, and your filesystem may not be. Since we ran into this problem very rare, we don't change the default behaviour. You can easily rename a file in a case-sensitive way and commit the change:
git mv name.txt NAME.TXT
If you're renaming a directoy, you'll do a two stage rename with a temp name:
git mv foo foo2 git mv foo2 FOO git commit -m "changed case of dir"