# check git version and that it is installed
git --version
# Check all git configs
git config --list
# Add config
git config --global user.name "user name"
git config --global user.email "hh@gmail.com"
# change your default Branch to main
git config --global init.defaultBranch main
# Initialize a repository from existing code
git init
# adds a [.git] folder that contains all information about your project
# So if you want to stop tracking with git you have to remove the [.git] folder
#Get status about tracking
git status

#Add files to staging area
git add -A
# or
git add .
# Remove files from staging area
git reset
Git commit = snapshot
- Making changes
- Staging changes (saving)
- Committing changes
# Our first commit
git add .
git commit -m "first commit"
#check status
$ git status
On branch master <- our anwser from your git status question
noting to commit, working directory clean <- our anwser from your git status question
# all files are tracked and summited to our LOCAL git repo
# Check Log
git log
# cloning a REMOTE Repo
git clone git@github.com:johanilsson/github101.git
# viewing information about the REMOTE repo
git remote -v
# all branch local and remote
git branch -a
# --- Pushing changes - commit changes ---
# commit local
git diff # show changes
git status # see files that is modified
git add -A # add to staging
git commit -m "commit message" # commit with changes
# then push
git pull origin main # pull any changes that have been made on MAIN
git push origin main
# | \ our branch
# name of our remote repo
# [1] Create a branch for desired feature
# create new branch
git branch newNiceStuff
#see braches
git branch
# change to newNiceStuff
git checkout newNiceStuff
# [2] Make changes to local repo
# see what is modified
git status
# add changes
git add . # for only adding one file git add file.name
# commit changes to LOCAL repo
git commit -m "look new hot stuff"
[3] After commit push branch to remote
# add new local repo with new branch to remote
git push -u origin newNiceStuff
git branch -a
# [4] Merge a branch
# checkout main local repo branch
git checkout main
# pull if changes on remote repo main branch
git pull origin main
# see branches that we have merge so far
git branch --merged
# marge newNiceStuff to main
git merge newNiceStuff
# push changes to remote repo
git push origin main
# [5] Delete branch
# check so branch is merged
git branch --merged
# -d <- deleted local
git branch -d newNiceStuff
# check local and remote branches.
git branch -a
# delete remote branch newNiceStuff
git push origin --delete newNiceStuff