You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6.1 KiB

title marp paginate theme
Project management 0. Git setup true true buutti

Project management 0. Git setup

Contents

What is Git?

  • Git is a version control tool originally created by Linus Torvalds in 2005
  • Keeps track of code changes
  • Can be used to backup code in the cloud
  • Enables cooperation with other team members
  • Ubiquitous in software development

Why version control?

  • Without version control, only one version of your code exists
    • What happens when you realize you made a mistake and need to roll back changes you've made?
  • You could use manual backups, or a cloud storage service
    • What happens if two people connect to a cloud service and edit the same file?
    • Or maybe not even the same file... What happens when you and your teammate have made changes to code and you need to combine your work into a single, working version?
  • Version control handles all the problems above, and you can focus on the important part: programming!
    • You can even try out some big changes that break your software completely
    • If that doesn't work out, just roll back into the last working version!

Git vs cloud storage

  • Git is different from cloud storage services like Dropbox, Google Drive or OneDrive
    • Instead of automatic syncing, you deliberately push to and pull from the cloud
    • Cloud services are easier for beginners
    • ...but in projects of more than one person, tracking changes would be a pain
  • Git is used via the terminal and has a steep learning curve
    • There are some visual tools like Sourcetree or Sublime Merge
    • To use them effectively, though, you must still understand how Git works

Remote storage services

  • Git could be used locally, but its usage is almost always combined with a developer platform — a remote storage service like GitHub, GitLab or BitBucket
    • These services can also double as a programming portfolio that can help getting hired into the industry
    • Commonly used in both open source and commercial projects
  • In Buutti's trainings, GitLab is most commonly used

w:150px

w:150px

w:150px

Setup

w:450px

  • Installing Git:
    • Windows/Mac: git-scm.com
      • Installation instructions are included in the following slides.
      • If a setting is not mentioned in the instructions, you can leave it as the default option.
    • Linux: sudo apt-get install git

Git setup: Settings for Windows

To set manually after setup, use:

git config --global core.editor "code --wait"

To set manually after setup, use:

git config --global init.defaultBranch main



To set manually after setup, use:

git config --global credential.helper wincred

Command line

  • Git is operated via the command line, a.k.a, the terminal
  • There are many kinds of command line syntaxes out there. Some examples:
    • Windows: PowerShell (new), cmd (old)
    • Linux, (also included in the Windows Git install): bash
  • We're using PowerShell, which can be accessed inside VS Code or Visual Studio
    • In VS Code, open/close terminal by pressing CTRL+Ö (in the Fin/Swe layout)

Basic commands and the working directory

  • To do actions in Git, you don't press buttons, you write commands
  • Most commands act on the currently open folder, a.k.a. the working directory
    • Path to the directory is shown next to the terminal cursor: PS E:\borb\code\unity-basics-course>
  • ls tells the contents of the working directory
  • cd is used to move to another directory
    • Use cd programming to move to the programming subfolder PS E:\borb\code\unity-basics-course\programming>
    • Use cd .. to move one step up in the hierarchy (to the parent directory) PS E:\borb\code\unity-basics-course>
  • Note: .. is a shorthand for to the parent directory, . for the current directory

Extra: Help, this is horrible!

  • Do you feel more at home in graphical UIs?
    • There are also graphical user interfaces for Git like Sublime Merge, GitKraken, or GitHub Desktop (for use with GitHub only)
    • VS Code also has very useful graphical tools for Git (more about them later!)
  • However, the GUIs make a lot more sense after you've understood the Git commands that those GUIs still execute under the hood
    • There is no free lunch here

Note: Config

  • After installation, you may configure your Git username for every project:
    • Use git config --global user.name "myUserName"
    • and git config --global user.email "my.email.address@domain.com"
  • If you do not do this, Git will ask to do it anyway at some point