Kosmas Hench
2021-02-22
The aim of this small task is two-fold:
Please start by creating a new empty repository which we are going to use for the workshop. I recommend naming the repository project_folder_xx (with xx being your initials) and placing it on your desktop (for now β you can remove it after Thursday).
Two things happen here: we create a new empty folder called project_folder_xx and then we initialize a git repository within this folder.
In the theme of the workshop, this would be visualized as this: and .
In gitkraken, doing this is quite straight forward - you can create a new folder with a repository by clicking the folder icon in the upper left corner:
Then you can specify the folder name and position (the βpathβ) on your computer:
Gitkraken goes an extra mile by also creating a readme file (README.md), which is usually wanted, but we will delete it to keep the dummy repository simple.
If you are feeling fancy and want to initialize the repository with the command line instead of using gitkraken, you can do this like so (donβt worry if you donβt know about the command line β the gitkraken approach works just fine π):
cd ~/Desktop
mkdir project_folder_xx
cd project_folder_xx
ls -a
#> . ..
git init
#> Initialized empty Git repository in /home/usr_name/Desktop/project_folder_xx/.git/
ls -a
#> . .. .git
Now, we want to add a small text file to the repository. The file is going to contain the text AAA and is going to be called A.txt. You can use any plain text editor for this, eg Notepad on Windows or TextEdit on Mac (note, this is plain text, NOT a text format like eg. MS Word .doc).
Again, the command line version to do the same thing:
echo "AAA" > A.txt
Now is the time to remember Viveks nice overview of git add, git commit and git push:
If we want to create a snapshot of our repository with the new file included, we need to stage this file (which is what the git add does). In gitkraken you can do this by clicking Stage all changes:
The command line way of doing this:
git add A.txt
With the changes in A.txt (and README.md) staged, we can now actually take the snapshot using git commit. Remember to add a super informative message to the commit (in the field Commit Message)
or:
git commit -m "added A"
At this point, your repository is in shape π. Yet, we still want to connect it to your github account.
In git speak we need to add a remote (connect to github) and then push the changes.
In gitkraken you can add a remote by clicking REMOTE in the left panel. Again, you can adjust the repository name (as displayed on github), as well as your account details. We are not going to do secret stuff here, so you can keep the repository public.
Gitkraken will direktly push the changes to github, so after clicking Create remote and push local refs, the dummy repository should pop up in your github account:
If you want to do this on the command line, Iβd recommend creating an empty repository directly on github and then:
git remote add origin https://github.com/k-hench/project_folder_kh.git
git push -u origin master
#> Enumerating objects: 3, done.
#> Counting objects: 100% (3/3), done.
#> Writing objects: 100% (3/3), 203 bytes | 203.00 KiB/s, done.
#> Total 3 (delta 0), reused 0 (delta 0)
#> To https://github.com/k-hench/project_folder_kh.git
#> * [new branch] master -> master
#> Branch 'master' set up to track remote branch 'master' from 'origin'.
If you made it this far: π Congrats youβre done! π
π