Quick Reference - Git
Not intended to be a tutorial on using Git, this is simply a page of my notebook, because I keep forgetting the commands I need. This assumes you have already configured your github username and password.
Once the directory / folder you want to version control has been created:
git init
check the status of git for this folder:
git status
Once files have been created within the folder, individually add them:
git add <file>
add all files with:
git add .
Commit your changes:
git commit -m "<description of what you changed>"
Create your new repository on github, copy the url
git remote add origin <URL>
Upload / Push your files up for the first time:
git push -u origin master
From here on... we can use:
To Push:
git push
To Pull:
git pull
Finally, more documentation with these commands:
man git
man git-push
man git-pull
Made changes on target, but I wish to pull the latest and greatest from git repository, overwriting any changes made on target:
git fetch --all
git reset --hard origin/master
git fetch downloads the latest from remote without trying to merge or rebase anything
git reset - resets the master branch to whatever you just fetched
The ‘--hard’ option changes all the files in your working tree to match the files in origin/master.
all credit belongs to:
https://www.linux.com/tutorials/introduction-using-git/
https://www.freecodecamp.org/forum/t/git-pull-how-to-override-local-files-with-git-pull/13216