Getting started with Git

Getting started with Git

SETUP

  • Set a name that is identifiable for credit when review version history

    git config --global user.name “[firstnamelastname]”

  • Set an email address that will be associated with each history marker

    git config --global user.email “[valid email]”

MOST COMMONLY USED GIT COMMANDS

  • Initialization of git

    git init

  • Add a file as it's ready for your next commit (stage)

    git add <file>

  • Add all files as they are ready for your next commit (stage)

    git add .

  • Show modified files in working directory, staged for your next commit

    git status

  • Commit your staged content as a new commit snapshot

    git commit -m “[descriptive message]”

  • Display the entire commit history using the default format.

    git log

  • Difference of what is changed but not staged

    git diff

Pushing an existing repository to GitHub

  • git remote add origin https://github.com/example/test3.git

  • git branch -M main

  • git push -u origin main

Cloning a repository

  • git clone https://github.com/example/test2.git

  • git fetch

  • git merge origin/main