We will use Git Bash: https://gitforwindows.org
Official git documentation https://git-scm.com/download/linux
if ypu do not have brew, install with:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
then
brew install git
In a terminal run the following command to set your username:
git config --global user.name "FIRST_NAME LAST_NAME"
set your email address:
git config --global user.email "MY_NAME@example.com"
If you do not have a GitHub account then please create one before: https://github.com
Git handles versioning and GitHub is the cloud service that hosts your code online.
git-tutorial/git-vs-github
There are several alternatives to GitHub. These are the most common:
Learning to do everything on the command-line gives a lot of flexibility, so this workshop as much as possible will be done on the commandline.
Go to users home directory that usually contains Documents
or Desktop
folders.
cd
Change directory to a specific folder
cd folder_name
Special folders in the commandline
.
current folder..
one folder back/higher/up/
the base of the operating system-
previous folder~
users home folder
pwd
List all current files/direcories in folder including hidden files
ls -la
ctrl+c
- will close any active program
touch filename.txt
mkdir folder-name
You might get asked if you really wanted to remove certain files. If you do not want the safety you can also use -f
rm -r folder
Most terminals have vi available. It is a benefit to know how to navigate it and recognise when you land in the editor. Vi is an older version of Vim (Vi improved). To start editing a file type:
vi filename.txt
Then press i
to go into --INSERT--
mode so you can type the text. (--INSERT--
will show at the bottom)
When you are done
If you get stuck you can always close the terminal window and start again.
Another editor that might show by default is Nano. This has a different interface compared to Vim.
For a more complete and structured tutorial check Git tutorial
On the commandline navigate to the folder .
git init
git status
git log
git diff
git add folder_or_filename
git commit -m "Description of what the changes were"
Conventional commit messages are often used in development teams as a guideline. Read more here: https://www.conventionalcommits.org/en/v1.0.0/
Generate key Configure it for your GitHub account
Follow https://www.w3schools.com/git/git_remote_getstarted.asp
To simulate 2 people working on a repository you can create two different folders and clone the repository in each. then you can work in the two folders independently.
The commands I used:
git rebase origin/main
# there was a conflict in myawesomefile.txt
git add myawesomefile.txt
git rebase --continue
# got a vim window at the end to confirm the commit messages so I typed :wq
After these commands the git status
shows you are 1 commit on top of main and the git log
command now has the extra commit.
Try it out!