Skip to content

Latest commit

 

History

History
117 lines (101 loc) · 3.03 KB

git.md

File metadata and controls

117 lines (101 loc) · 3.03 KB

Git Hub

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

  • Set your git user name

      git config --global user.name "<your_name_here>"
  • Set your git e-mail

    git config --global user.email "<[email protected]>"

Where to install?

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).

  1. If you change a document locally (in your computer),
  2. Add your file to your github with git add .
  3. Confirm that you saved the change with git commit -m 'Yes, I want to commit my last change', and
  4. Upload your changes using git push to your online git.

Note: There are new methods to create your git password, just go to your github settings, then to developer settings, click on Personal Access Tokens and generate a new token. Save the token in a safe place.

  • Checking status

    git init
    git status
  • Clonning repository

    git clone http://github.io/user_name/repository_name
  • Adding files

    git add .
  • Commiting files in-line commenting

    git commit -m 'first commit of files'
  • Execute

     git push
     git pull

    if problems persist, force

     git push -f

One commit ahead

  • Commit the change using

    git commit -m "My message"
  • Stash it.

    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
  • Discard the local changes

    Using

    git reset --hard

    or

    git checkout -t -f remote/branch
  • Discard large files, if commited large files mistakenly

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'

To remove unwanted changes

git log
git rebase -i stash
#change from pick to drop
git log # to confimr drops
git push -f