Skip to content

Instantly share code, notes, and snippets.

@rahmatrhd
Last active May 18, 2019 09:26
Show Gist options
  • Save rahmatrhd/2088a79df5b29223a0a9d2768c702942 to your computer and use it in GitHub Desktop.
Save rahmatrhd/2088a79df5b29223a0a9d2768c702942 to your computer and use it in GitHub Desktop.
First Time to Git

Cloning Repository and Basic Stuff

1. Clone from remote repository

  1. Click on the "Clone or download" button
  2. Copy the URL. Chose "Clone with HTTPS" if you haven't setup your SSH
  3. Run git clone https://github.com/USERNAME/REPOSITORY_NAME.git in your terminal

2. Navigate to cloned repository

  1. After you cloning a repository, usually it make a new folder within you current directory named the same as REPOSITORY_NAME
  2. Navigate into it by running cd REPOSITORY_NAME
  3. If you want to open your current directory on text editor for example VSCode, run code . to open VSCode

3. Make changes

  1. Try to edit a file or create a new file
  2. Check your changes with git status. You will see file name(s) with red color
  3. Or with git diff if you want to see the changes detail. You can quit by pressing q

4. Add changed file(s) to staging area

  1. git add file_1.txt path/to/file_2.txt. With this you are adding two files which are file_1.txt and file_2.txt (placed inside path/to/ directory) at once
  2. You also can run git add . to add all the changed files

5. Commit

  1. Run git status again to make sure that you have any files with green color (green color means they're added into staging area)
  2. Run git commit -m "BRIEFLY TYPE WHAT CHANGES YOU'VE MADE HERE". An informative message would help in the future.
  3. Make sure you get x files changed, y insertions(+), z deletions(-) feedback

6. Push to your remote repository

  1. Run git push origin master. Assuming you are in branch master or forget this sentence if you have no idea what is it
  2. If you get asked for login, login using your github username and password
  3. Check the repo in your github profile to make sure you did this correctly. Maybe you'll get a little happiness seeing your commit message existed there :)

Course

Done this course to deepen your git skill https://egghead.io/courses/practical-git-for-everyday-professional-use

First time set up

1. Install git into your machine

Make sure git installed properly by running git --version in your terminal. You will get shown the current version of git you are installed

2. Set up with your email and username

  1. Run this git config --global user.name "Your Name"
  2. and this git config --global user.email "your_email@example.com"

3. Done

Yes it is

Set up SSH

1. Check your existing ssh

Check if you have ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub existed already

2. If NOT, create one

Run this in your terminal ssh-keygen -t rsa -C "your_email@example.com"

3. Copy your public key to clipboard

Copy everything inside id_rsa.pub

4. Add ssh in your github account

  1. Go to github account settings > SSH and GPG keys
  2. New SSH key
  3. Give a descriptive title and paste your public key

5. Test it

  1. Run ssh -T git@github.com in your terminal
  2. Succes message example:
Hi username! You've successfully authenticated, but Github does not provide shell access.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment