Scala notes

Git step by step

 

Git basics

Before all this, we must have ssh key added to gitlab / github

Check username and email
git config user.name
git config user.email

Set username and email
git config user.name Someone
git config user.email someone@something.com
Use option --global to set it globally, for all future projects

Go to folder where we want to init the repo
git init #initializez a git repo

Add a new remote to be used.
For remote_name `origin` is usually used; url is taken from gitlab/github page
git remote add <remote_name> <url>

Fetch everything (all branches) from remote
git fetch

Change to another branch
git checkout <branch_name>

Update a branch - usually done after moving to it
git pull <remote_name> <branch_name>
If already on a branch, short version can be used
git pull

Add new/modified files to be commited
git add <relative_path/to/file/or/folder>

Commit added files
git commit -m "Commit message"

Push changes
git push -u <remote_name> <branch_name>


Commit to new branch, with issue fix and ready for merge request

Change necessary files on the master branch (for example, since everything should be relative to master)

Create new branch
git checkout -b <new_branch_name>
This will create the new branch, add everything to it and move to the new branch

Add changes to be commited
git add relative/path/to/files

Commit changes on the new branch, specifying what issue this commit fixes
git commit -m "Commit message. Fixes#<issue_number>"

Push everything (the new branch, changes, everything)
git push -u <remote_name> <new_branch_name>

Now go to github / gitlab and create a merge request.