Changes

Jump to navigation Jump to search
2,830 bytes added ,  10:45, 15 September 2020
push all the things! ;)
=== Git ===
Please always use useful commit messages.
 
Git is a version control tool for source code and text files.
We use it for working on projects together.
* [http://git-scm.com/book Official Git-Book]
* Tutorials** https://www.atlassian.com/de/git/tutorial/git-basics** [http://git-scm.com/docs/gittutorialTutorial]* [https://gitgitea.zom.bi/ Our GitlabGitea]=== Commiting on the docker-host ===
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.
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
 
== Migrate a project from GitLab to Gitea ==
 
Create your project on [[/Gitea|Gitea]] here: https://gitea.zom.bi/repo/create
 
# Clone using the --mirror flag (It will clone all branches into a bare repo)
git clone --mirror https://git.zom.bi/username/project.git
# Add new remote
git remote add gitea "https://gitea.zom.bi/username/project.git"
# Push to Gitea
git push -u gitea --all
git push -u gitea --tags
[[Category:Documentation]]

Navigation menu