Difference between revisions of "Git"
m (Adding url) |
(Migrate tutorial from old wiki) |
||
Line 17: | Line 17: | ||
* [http://git-scm.com/docs/gittutorial Tutorial] | * [http://git-scm.com/docs/gittutorial Tutorial] | ||
* [https://git.zom.bi/ Our Gitlab] | * [https://git.zom.bi/ Our Gitlab] | ||
− | + | == Commiting on the docker-host == | |
use the compact alias <code>git ''username''-commit</code> to commit with your user information. | use the compact alias <code>git ''username''-commit</code> to commit with your user information. | ||
''git-push'' all the changes often, so collaboration becomes easier. | ''git-push'' all the changes often, so collaboration becomes easier. | ||
Please always use useful commit messages. | Please always use useful commit messages. | ||
+ | |||
+ | == Basics == | ||
+ | This is a guide that bsod wrote as a quick overview for the colleagues at work. | ||
+ | |||
+ | === Clone === | ||
+ | creates a local copy of the repository including all branches (for initial setup) | ||
+ | <code> | ||
+ | git clone http://XXXXXXXXXXXXXXXXXXXXXXX | ||
+ | </code> | ||
+ | === Update Repository === | ||
+ | this updates the changes from the origin (gitlab server) | ||
+ | <code> | ||
+ | git pull | ||
+ | </code> | ||
+ | === Committing Changes === | ||
+ | In this example you have created a file ("somefolder/somefile") and edited it | ||
+ | <code> | ||
+ | # if the file is new, add the file to be commited | ||
+ | git add somefolder/somefile | ||
+ | # make a commit of the changes | ||
+ | git commit -m "i made some changes to a new file" | ||
+ | </code> | ||
+ | |||
+ | if you change this file you don't need the git add command the next time. | ||
+ | |||
+ | === Push committed changes to server === | ||
+ | unlike svn files are not uploaded to the server on commit. run the following command in order to push code to the server | ||
+ | <code> | ||
+ | git push | ||
+ | </code> | ||
+ | |||
+ | === Status === | ||
+ | You can check the status of your repostory (list which files have been changed since the last commit) | ||
+ | |||
+ | <code>git status</code> | ||
+ | if nothing has been changed | ||
+ | <code>> git status | ||
+ | Auf Branch master | ||
+ | Ihr Branch ist auf dem selben Stand wie 'origin/master'. | ||
+ | nichts zu committen, Arbeitsverzeichnis unverändert</code> | ||
+ | if you did change something which hasn't been commited yet | ||
+ | <code>> git status | ||
+ | Auf Branch master | ||
+ | Ihr Branch ist auf dem selben Stand wie 'origin/master'. | ||
+ | Änderungen, die nicht zum Commit vorgemerkt sind: | ||
+ | (benutzen Sie "git add <Datei>...", um die Änderungen zum Commit vorzumerken) | ||
+ | (benutzen Sie "git checkout -- <Datei>...", um die Änderungen im Arbeitsverzeichnis zu verwerfen) | ||
+ | geändert: bind/Dockerfile | ||
+ | keine Änderungen zum Commit vorgemerkt (benutzen Sie "git add" und/oder "git commit -a")</code> | ||
+ | |||
+ | === Branching === | ||
+ | ==== Create a Branch ==== | ||
+ | |||
+ | a) just create a branch | ||
+ | git branch branchname | ||
+ | |||
+ | b) create a branch and switch to it automatically (recommended) | ||
+ | git checkout -b branchname | ||
+ | |||
+ | ==== Switch to a different Branch ==== | ||
+ | switches to another existing branch ("another-branch") | ||
+ | git checkout another-branch | ||
+ | |||
+ | ==== Delete a branch ==== | ||
+ | a) delete a local branch | ||
+ | git branch -d branchname | ||
+ | |||
+ | b) delete a remote branch on origin | ||
+ | git push origin :branchname | ||
+ | === Revert Files === | ||
+ | sometimes it is necessary to revert files to the status which is in git (because you broke something or edited a file while being in the wrong branch for example) | ||
+ | |||
+ | revert a single file | ||
+ | git checkout -- filename | ||
+ | |||
+ | revert the whole repository to the status of the last commit. | ||
+ | git reset --hard | ||
[[Category:Documentation]] | [[Category:Documentation]] |
Revision as of 12:41, 8 June 2020
Gitlab status: stable | |
---|---|
Description | Version Control tool |
URL | https://git.zom.bi |
Maintainer | User:Madmaurice |
Authentication | LDAP |
Git is a version control tool for source code and text files. We use it for working on projects together.
Contents
Commiting on the docker-host
use the compact alias git username-commit
to commit with your user information.
git-push all the changes often, so collaboration becomes easier.
Please always use useful commit messages.
Basics
This is a guide that bsod wrote as a quick overview for the colleagues at work.
Clone
creates a local copy of the repository including all branches (for initial setup)
git clone http://XXXXXXXXXXXXXXXXXXXXXXX
Update Repository
this updates the changes from the origin (gitlab server)
git pull
Committing Changes
In this example you have created a file ("somefolder/somefile") and edited it
- if the file is new, add the file to be commited
git add somefolder/somefile
- make a commit of the changes
git commit -m "i made some changes to a new file"
if you change this file you don't need the git add command the next time.
Push committed changes to server
unlike svn files are not uploaded to the server on commit. run the following command in order to push code to the server
git push
Status
You can check the status of your repostory (list which files have been changed since the last commit)
git status
if nothing has been changed
> git status
Auf Branch master
Ihr Branch ist auf dem selben Stand wie 'origin/master'.
nichts zu committen, Arbeitsverzeichnis unverändert
if you did change something which hasn't been commited yet
> git status
Auf Branch master
Ihr Branch ist auf dem selben Stand wie 'origin/master'.
Änderungen, die nicht zum Commit vorgemerkt sind:
(benutzen Sie "git add <Datei>...", um die Änderungen zum Commit vorzumerken)
(benutzen Sie "git checkout -- <Datei>...", um die Änderungen im Arbeitsverzeichnis zu verwerfen)
geändert: bind/Dockerfile
keine Änderungen zum Commit vorgemerkt (benutzen Sie "git add" und/oder "git commit -a")
Branching
Create a Branch
a) just create a branch
git branch branchname
b) create a branch and switch to it automatically (recommended)
git checkout -b branchname
Switch to a different Branch
switches to another existing branch ("another-branch")
git checkout another-branch
Delete a branch
a) delete a local branch
git branch -d branchname
b) delete a remote branch on origin
git push origin :branchname
Revert Files
sometimes it is necessary to revert files to the status which is in git (because you broke something or edited a file while being in the wrong branch for example)
revert a single file
git checkout -- filename
revert the whole repository to the status of the last commit.
git reset --hard