Skip to content

Git Information

GeorgPessler edited this page Dec 6, 2017 · 8 revisions

Basic information about git

Basic information about Git you can find on this official page. There are also some introduction sources. Further information about interesting sources you can find in the last section.

Setup

Download and installation

First you have to install the Git software on your local computer. Basically you just need Git, which you can get here. There is also the option to install additional software like Tortoise Git that provides a graphical user interface. In this introduction we just use the Git command line tool “Git CMD” and no additional graphical ui. If you are interested, you can find a collection of gui software on this site.

Configuration

After the installation you need to do some configurations of Git. To list the currently used configurations open the Git CMD and use the command:

git config --list

Now it is time to set your username and your email address. This way it is clear which developer did which commit and people can contact you if they have a question or found a mistake. To set the two informations use the commands:

git config --global user.name "YOUR USERNAME"

git config --global user.email "YOUR@USEREMAIL.COM"

In case you work behind a proxy server, as it happens often in companies, you have to add some additional proxy information with the following command:

git config --global http.proxy "https://USERNAME:PASSWORD@PROXYADDRESS"

The information you need is:

  • The username for your account
  • The passwort for your account
  • The IP address or domain of the proxy

If you want the version control to ignore special files of your project, you can do this by adding a special file to your working directory called:

.gitignore

Inside this file you can list a specific file that should be ignored, or you can use wildcards to ignore complete groups of files:

fileIWantToIgnore.txt (ignore exactly this file)

*.c (ignore all files with the ending .c)

You can see the syntax and a list of common commands grouped by usage if you just type:

git

If you need help to use a specific command you can get it with one of these two commands:

git help <COMMAND>

git <COMMAND> --help

A list of available commands you can get with:

git help -a

A list of different available concept guides you can access via:

git help -g

Workflows

Here are described just two possible workflows for contributing to the original BuildingControlLib. Of course Git can used in more ways than this, i.e. for version control of a project that is stored just on your local machine. Such cases we do not describe here.

In both described ways we expect an existing server sided repository that you want to contribute to, i.e. an existing project on GitHub like the BuildingControlLib.

Working with a branch

In this case you search for the URL of the project. In our case this would be "https://github.com/TechnicalBuildingSystems/BuildingControlLib". You can find it on the GitHub page of the project, via the button "Clone or download".

Working with a fork

Command reference

Command Result
git lists syntax and most common commands grouped by application
git help -a lists all available commands
git help -g lists all available concept guides
git help <COMMAND> get help for a special command
git <COMMAND> --help get help for a special command
git config --list list all configurations (PROPERTY=VALUE)
git config --global PROPERTY "VALUE" configure a property
git config --global user.name "USERNAME" configure the username
git config --global user.email "EMAIL_ADDRESS" configure the email address
git config --global http.proxy "IP_OR_DOMAIN" configure the proxy server
git remote show all tracked repositories
git remote -v show all tracked repositories verbosely
git branch -a show all local and remote branches
git branch BRANCHNAME1 create new branch BRANCHNAME
git checkout BRANCHNAME2 switch to the branch BRANCHNAME
git checkout -b BRANCHNAME create new branch BRANCHNAME and switch there (shorthand for 1 and 2)
todo todo
git status todo
git add todo
git commit todo
todo todo
git pull shorthand for git fetch + git merge
git fetch update from remote
git merge todo
git pull origin next pull changes from the branch next of repository origin to your currently choosen working branch (same as two next commands together)
git fetch origin todo (notice that you might have to do git add + git commit afterwards, before git merge)
git merge origin/next todo
todo todo
git push works like git push IF a has been set OTHERWISE it works like git push origin
git push <remote> todo
git push origin pushes the current active branch to the configured upstream IF it exists OTHERWISE an error occurs and nothing happens
git push origin : push MATCHING branches to origin
git push origin NAME find branch NAME locally and update branch NAME of origin or build it in case it doesn't exist
git push origin HEAD push current branch to same branch in origin
git push origin HEAD:NAME push current branch to branch NAME in origin
todo todo
todo todo
todo todo

Helpful links