DEV Community

Cover image for Begginer friendly on git bash commands and git hub
Ibrahim Khalif
Ibrahim Khalif

Posted on

Begginer friendly on git bash commands and git hub

How to download GitBash on your computer.

-Visit Git Bash
-Download the Windows installer
-Run the installer with these recommended settings:
    -Select "Use Git from Git Bash only "
    -Choose "Use the OpenSSL library"
    - Select "Checkout Windows-style, commit Unix-style line endings"
    -Choose "Use MinTTY"
    -Leave other options as default
Enter fullscreen mode Exit fullscreen mode

For Mac Users:

  • Install Homebrew (if not installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode
  • Install Git:
brew install git
Enter fullscreen mode Exit fullscreen mode
  • Verify:
git --version
Enter fullscreen mode Exit fullscreen mode

How to push codes on git bash

  • When one whant's to check the version he/she is using
git --version
Enter fullscreen mode Exit fullscreen mode
  • When you need help
git help
Enter fullscreen mode Exit fullscreen mode
  • If you want to create a repository we use th command,
git init 
Enter fullscreen mode Exit fullscreen mode

while for existing repository we use

git clone <url>
Enter fullscreen mode Exit fullscreen mode
  • When you want to configure your name we use the following commands.
git config --global user.name "Your Name"
git config --list (*when you want to list your configutration*)
Enter fullscreen mode Exit fullscreen mode
  • How to create ssh key we use
ls ~/.ssh
Enter fullscreen mode Exit fullscreen mode
  • When you want to make ssh key we use
ssh-keygen -t ed25519 -c (*followed with your email address*)
Enter fullscreen mode Exit fullscreen mode
  • When you want to create ssh agent we use
eval"$(ssh-agent -s)
Enter fullscreen mode Exit fullscreen mode
  • When you want to create a folder in git bash
mkdir (your folder name)
Enter fullscreen mode Exit fullscreen mode
  • When you want to get into the folder you have create we use
mkdir cd
Enter fullscreen mode Exit fullscreen mode
  • If you want touch a file in the existing folder
touch (folowed by file name)
Enter fullscreen mode Exit fullscreen mode
  • if you want to make branches on git bash
git branch               # List branches
git branch new-branch    # Create branch
git checkout new-branch  # Switch branch
git checkout -b new-one  # Create & switch
git merge branch-name    # Merge branch
Enter fullscreen mode Exit fullscreen mode
  • when you want to Undo / Fix Mistakes on GitBash
git restore file.txt
git reset HEAD file.txt
git reset --hard
Enter fullscreen mode Exit fullscreen mode
  • When you want to save you work temporarily on GitBash we use
git stash
git stash list
git stash po
Enter fullscreen mode Exit fullscreen mode
  • When you want to view your past history we use the following commands
git log
git log --oneline
git diff
Enter fullscreen mode Exit fullscreen mode
  • Connecting git bash to git hub we use
ssh .T git@github.com
Enter fullscreen mode Exit fullscreen mode

Top comments (0)