Git and GitHub Tutorial for Beginners¶
Userful Links¶
Turtorial on Youtube.
Get Git¶
https://git-scm.com
-
Hit ‘Downloads’
-
Select your operating system and then run through the installation process
-
With Git Installation, it came with a termianl called Git Bash.
Launch Gitbash: Click on your Start menu and type in Git Bash
windows view:
Once you’ve installed Git, you can use any terminal now to interact with Git. For this lesson, I am going to use Git Bash because it came with the Git installation on Windows. If you want, you could also download third party teminals like Hyper.is, which works across all different paltforms.
Use Git¶
- Git Configuration:
To credit your identity, we need to specify your name and e-mail address:
git config --global user.name "type your name"
and then hit Enter, next set your e-mail address:
git config --global user.email yourEmail@xxxx.com
We need to set the default branch name:
git config --global init.default branch main
Ask for help
git config -h
Check Git-config Manual Page (no internet access required),check the descriptions of commands, the options of the commands, and etc.
git help config
Back to File Explorer , to clear the history and get a fresh view, type clear
To track files on your computer, first, change the current directory to the location of the file:
Back within Git Bash, cd
change directory
Now, to turn this into a Git repository,
type git init
or git initialize
Now, if you click on ‘show hidden files’, you should see a .git
file, which indicates that the file has been converted to a git repository.
Check the status of the repository: git status
To track a specific file , type git add <file>
To confirm a file being tracked, type git status
again;
To unstage(stop tracking) a tracked file, type git rm --cached <file>
Tips:
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; An example of ignoring .txt files being tracked: Create a file with the extension ‘.gitignore’ and open it with any text editor, type.txt
and save the file.