GitHub

To install github there are 2 ways

  1.  Git (for Windows & Mac) Download Link: https://git-scm.com/downloads
  2.  GitHub Desktop will launch. link

1.setup (git)

Step1: Git (for Windows & Mac) Download Link: https://git-scm.com/downloads

Step 2:  After your download is complete, run the .exe file in your system and Click Next to choose where to install Git on your computer

Step 3:This is the step to choose the installation location, the default is C:\Program Files\Git. You can change it by clicking the Browse button next to it and choosing a different installation location.

Step 4: Click Next, a window will appear to select the components to be installed. After you select your desired components, Click Next

note: If you add any components, the capacity after installation will increase compared to the default 260MB

Click Next to choose where to install Git on your computer 

 Step 5: In this step, you choose a default “editor” for Git (visual code, Note ++, Sublime text..

.

 This step you choose by default => then click Next to continue.

Step6:Next is the step where we customize the environment variable. You choose item 2 because it is Recommended (recommended/recommended) => Then click Next to continue

.

 This step you choose by default => then click Next to continue.

Step7:The next step is to choose the connection encryption features for your Git. If you are a student or a new developer who is not familiar with what SSL/TLS is, then choose the second option. Click Next to continue

 

The next screen prompts you to choose the format to convert after finishing command line operations with Git. Select option 2 to match GIT’s built-in Linux line-ending standards. Roughly speaking, with this option, Windows users will have text files converted from style line endings Windows( ) to style line endings Unix( ) as they are added to the archive. This is more secure about the storage mechanism in Git when you want to review Log or Status. Click Next to continue.

Step 8: Command line emulator configuration screen to use Git Bash. You can choose 1 of 2, but I personally use MinTTY. Because MinTTY is a software that emulates Git’s default command line interface relatively well, it provides additional features like drag and drop, full screen, copy and paste, and theme support to help them operate more conveniently with the command line. Click Next to continue

The default configuration when you run git pull to sync code from Remote Repository to Local Repository.

Step 9:This step you just choose by default and then continue.

Step 10: This step should not be checked because this function is new and has some errors. Click Install to start the installation.

Installation takes about 1 minute or less. After the installation, click Finish to finish the installation process.

Step 11: Finally, verify that Git is installed correctly ( open your Command Prompt)

git –version : Check your version git

Step12: Run the following commands with your information to set the default username and email when you will save your work.

git config –global user.name “Tester”

git config –global user.emailexample@mail.com

Note: the email must be the same as the one you registered with Github

after adding use: git config –list

2. Git User Guide

Before going into using git we need to understand some concepts related to Git as follows:

Repository: Repository simply understands it as a repository of all the information needed to manage the revision and history of the entire project. Git’s repository is divided into two types: remote repository and local repository.

  • Local Repository: is the repository located on our own computer, this repository will synchronize with the remote repository by git commands.
  • Remote Repository: is a repository installed on a dedicated server. For example: GitHub, GitLab, Bitbucket,…

=> GitHub is a Remote Repository that stores all the information needed to manage the revision and history of the entire project.

Working tree and Index (or staging area): These are the directories placed in Git management where people do work, called the working tree. Between the repository and the working tree exists a place called the index or staging area. The staging area is the place to prepare for the commit to the repository.

2.1 Commands:  git init

Effect : Initialize a local Git repository.

using :Using : Create a new folder => go into that folder => right click and choose Git Bash Here as shown below

The git bash console window appears => you type the command git init

After successful creation, in the folder will appear a .git folder => this folder will contain all the necessary information to manage the revisions and history of the entire project. If you want to delete this file, think before you delete it: EASY 😀

2.2 link Repositories GitHub 

  1. Create account
  2. Create new Repositories

Click button Create repository

  1. copy path

 

  1. Open git bash

$ git remote add origin //git@github.com/[username]/[repository-name].git

Tip: if you want View existing remotes using: git remote -v

if you want change remote using: git remote set-url origin

  1. create a file in the directory

create 1 file (html, txt …) in the folder you have set up the environment (git)

2.3 Commands : git add

Effect: Add changes to stage / index in directory work.

using: git add  test.html

When add is successful

tip: Add all new and changed files to the staging area : git add -A

Effect: commit is an action for Git to save changes in the working directory to the repository

using: git commit -m ” test”

When commit success

Tip: edit the commit using $ git commit –amend -m “Test HTML”

2.6 Commands: git push origin

Effect: Push a branch to your remote repository

using: git push origin [branch name]

when push success

open your project on GitHub web (Your files have been uploaded)

2.7 Commands: git fetch and git pull

effect:

Create new file in your project

after create file (test 2)

open your Git Base

step 1: setup stream origin :git branch –set-upstream-to=origin/ master

step2: run git fetch

step 3: run git pull

step4 : check your work directory

 

your working directory is updated like the Remote Repository

3.1 Getting & Creating Projects

Command Description
git init Initialize a local Git repository
git clone ssh://git@github.com/[username]/[repository-name].git Create a local copy of a remote repository

3.2 Basic Snapshotting

Command Description
git status Check status
git add [file-name.txt] Add a file to the staging area
git add -A Add all new and changed files to the staging area
git commit -m “[commit message]” Commit changes
git rm -r [file-name.txt] Remove a file (or folder)

3.3 Branching & Merging

Command Description
git branch List branches (the asterisk denotes the current branch)
git branch -a List all branches (local and remote)
git branch [branch name] Create a new branch
git branch -d [branch name] Delete a branch
git push origin –delete [branch name] Delete a remote branch
git checkout -b [branch name] Create a new branch and switch to it
git checkout -b [branch name] origin/[branch name] Clone a remote branch and switch to it
git branch -m [old branch name] [new branch name] Rename a local branch
git checkout [branch name] Switch to a branch
git checkout – Switch to the branch last checked out
git checkout — [file-name.txt] Discard changes to a file
git merge [branch name] Merge a branch into the active branch
git merge [source branch] [target branch] Merge a branch into a target branch
git stash Stash changes in a dirty working directory
git stash clear Remove all stashed entries

3.4 Sharing & Updating Projects

Command Description
git push origin [branch name] Push a branch to your remote repository
git push -u origin [branch name] Push changes to remote repository (and remember the branch)
git push Push changes to remote repository (remembered branch)
git push origin –delete [branch name] Delete a remote branch
git pull Update local repository to the newest commit
git pull origin [branch name] Pull changes from remote repository
git remote add origin ssh://git@github.com/[username]/[repository-name].git Add a remote repository
git remote set-url origin ssh://git@github.com/[username]/[repository-name].git Set a repository’s origin branch to SSH

3.5 Inspection & Comparison

Command Description
git log View changes
git log –summary View changes (detailed)
git log –oneline View changes (briefly)
git diff [source branch] [target branch] Preview changes before merging

 

Buy us some coffee

Thank You for your support as we work to give you the best of guides and articles.

top