|
|
# Define how we work together and how to use git
|
|
|
Just to set the base, here is a short how-to on how to work as a group on a git project.
|
|
|
|
|
|
## Set base
|
|
|
We have two main branches. We have the "master" branch and the "develop" branch
|
|
|
On the "master" branch we will have a stable version of our code base. On the "develop" branch we add new code ( by merging other branches into the develop branch). so when we work on our own
|
|
|
1. `git pull origin develop`
|
|
|
2. `git checkout -b "BRANCH-WITH-FUNCTIONAL-NAME"
|
|
|
3. add your code
|
|
|
4. For the love of god, TEST what you did, test if you can still build your application, make sure it does not crash. if it crashes, you are not finished and you need to fix that shit
|
|
|
4. `git add YOUR-FILE`
|
|
|
5. `git commit -m "TELL US WHAT YOU CHANGED"`
|
|
|
6. `git push --set-upstream origin BRANCH-WITH-FUNCTIONAL-NAME`
|
|
|
7. Then you can create a new merge request. for that you go to gitlab and on the left-side-navigation you find the section "Merge Requests"
|
|
|
![image](uploads/5d22faf70e8abd6302b9edee5791338c/image.png)
|
|
|
8. Click on create new merge request
|
|
|
9. Select the source branch - that is the branch you just pushed so BRANCH-WITH-FUNCTIONAL-NAME and set the target branch to "develop" e.g. ![image](uploads/6044834b961f6d6cfb80c16c35825e77/image.png)
|
|
|
10. then create the merge request and ask a team member to review your changes and then merge it
|
|
|
|
|
|
|
|
|
Once a week we test the develop branch altogether. If everything seems to be stable we create a merge where we merge the develop branch into the master branch
|
|
|
|
|
|
With that, we ensure that we always have a stable fallback
|
|
|
|
|
|
## Git in the IntelliJ terminal / Terminal
|
|
|
|
|
|
at the bottom left you have a terminal, open it
|
|
|
![image](uploads/e2f7ee733cc5bbced4529ec542b9a1ec/image.png)
|
|
|
|
|
|
with
|
|
|
``` git status```
|
|
|
you see what files you've changed
|
|
|
with
|
|
|
`git add /path/to/changed/file` you can add the file you changed to a commit
|
|
|
with
|
|
|
`git commit -m "what did you change/add describe in few words"`
|
|
|
with
|
|
|
`git push`
|
|
|
|
|
|
sometimes you need to add more to the push, but you will see in the terminal what to type. so just go with the suggested
|
|
|
after that you should find your changes on your branch on gitlab and you can open a merge request from there
|
|
|
|
|
|
with
|
|
|
`git branch`
|
|
|
you see on which branch you are at the moment and what other branches you have
|
|
|
![image](uploads/255bb02ce22b699a2d11a4a03e4e70b8/image.png)
|
|
|
this example above shows that I am currently on branch "update-work"
|
|
|
|
|
|
to check out a different branch like for example the develop branch. you need to commit your changes the way you used to do it on your branch.
|
|
|
then type
|
|
|
`git checkout develop`
|
|
|
do a
|
|
|
`git branch` and see that now the 'develop' branch is highlighted.
|
|
|
|
|
|
To get the newest version of develop from the gitlab you must type
|
|
|
`git pull origin develop`
|
|
|
|
|
|
when you are doing some work and want to create a new branch you do
|
|
|
`git checkout -b "NEW-BRANCHNAME"` |