Git is a version control platform that helps you to organize, collaborate and share your scripts. You can open a free account for github
Check this GitHub cheatsheet: https://training.github.com/downloads/github-git-cheat-sheet/
After opening the accout, just follow up the instructions for setting up you GitHub account:
You need to open your
terminal
-
git config --global user.name "<your_name_here>"
-
git config --global user.email "<[email protected]>"
I'd like to create a local folder to clone repositories, but you don't need to create this direcotory.
mkdir local_git
cd local_git # to enter to this directory
git clone htpps://github.com/repository_to_clone # per example `https://github.com/ricardoi/cqls_osu/`
You can enter to this repository/directory and you can see your github files, and you can open your file with the terminal.
cd cqls_osu/git/
open -a 'RStudio' README.md # Mac Only
After setting up your account, you can start using your git
Note: remember that you have your local git (on your personal computer) and your remote git (on your GitHub website).
- If you change a document locally (in your computer),
- Add your file to your github with
git add .
- Confirm that you saved the change with
git commit -m 'Yes, I want to commit my last change'
, and - Upload your changes using
git push
to your online git.
Note: There are new methods to create your
git password
, just go to your githubsettings
, then todeveloper settings
, click onPersonal Access Tokens
and generate a new token. Save the token in a safe place.
-
git init git status
-
git clone http://github.io/user_name/repository_name
-
git add .
-
git commit -m 'first commit of files'
-
git push git pull
if problems persist, force
git push -f
-
git commit -m "My message"
-
Stashing acts as a stack, where you can push changes, and you pop them in reverse order.
To stash, type
git stash
Do the merge, and then pull the stash:
git stash pop
-
Using
git reset --hard
or
git checkout -t -f remote/branch
To remove at commiting
git filter-branch --tree-filter 'rm -rf PATH_TO_FILE' HEAD
OR To remove after committing it first
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch PATH_TO_FILE'
git log
git rebase -i stash
#change from pick to drop
git log # to confimr drops
git push -f