Git & GitHub#
Git installation - Windows/WSL#
Git repo guide#
Initializing a local repo#
Create a project directory and initialize a new local repo:
mkdir NewProject
cd NewProject
# if using git > 2.28.0, you can create a root branch named "main" right away:
git init -b main
# this will make pushing to remote repo easier
# otherwise start with:
git init
Working with repo tracking#
work on your project
use following commands to stage the files for the commit
git add . # in case of all files
git add *.ipynb # in case of just .ipynb files for instance
to make tracking exclusion of certain files/folders easier, create a .gitignore file which will specify what will never be tracked
# when in working dir
touch .gitignore | nano
# add exceptions, eg. for jupyter notebooks it would be
**/**/ipynb_checkpoints
#check "More info" for Atlassian's guide on gitignore patterns
use following command to check the staging status of the repo and current branch
git status
to remove a file from staging for commit, use following (remember about –cached option!!)
git rm --cached FILE
git rm -r --cached DIR
# or, safe choice:
git reset -- HEAD FILE/DIR
when you’re ready to call it a day, make a commit
git commit -m "Commit summary"
GitHub guide#
create or use an existing account
generate a PAT (personal access token) - will be needed for pushing from local to remote repo through https
Settings -> Developer settings -> Personal access token
Save it somewhere safecreate a new repo without README.md and .gitignore files
copy the https URL
in your local repo directory use following, pasting the https URL:
git remote add origin HTTPS
to confirm connecting a remote repo, type:
git remote -v
let’s change root branch name so it is possible to push it to remote repo
git branch -m master main
to push the commits from local main branch to remote repo:
git push origin main
git will ask you for GitHub user name and password, which in this case is the PAT (personal access token)