Contents
Intro
This page is mainly for my notes when I haven’t done git in a while, more than an actual tutorial.
Prerequisites
- Choose which git provided you wish to go with, I went with bitbucket.
- You should have git installed at this point.
- Change into the top level directory , if my git repository is lampadmins, when I will clone, it will make the lampadmins directory first with all the git contents.
Initial and Clone git
initialize a git repo.
git init
Clone remote repository
git clone username@hostname:/path/to/repo
Cloning into an existing directory
git initgit remote add origin INSERT GIT URL HEREgit remove -vgit fetch origin
Add and remove to the index/staging
What is an index?
Add changes to INDEX
git add <FILENAME>
Add all changes to INDEX
git add *
Remove file from the index
git rm <FILENAME>
Making Commits.
What is a Commit??
Commit your changes to index/staging
git commit
Commit your chances along with the commit message
git commit -m “Commit Message”
Push changes to remote repository
git push origin master
Git Branching
What is Git Branching?
What is Git Checkout?
List all local git branches
git branch
List all remote branches
git branch -a
Create a new local branch
git branch branch_name
Checkout and start working on the branch
git checkout branch_name
Merge changes between Branch
git merge branch_name
Status and logs
git status
git log
List your current git config settings
git config –list
Git Difference
compare my local file with a branch
git diff master:main.yaml main.yaml
How to discard changes and reset file
git checkout main.yaml origin master
compare my local file with a branch
git diff master:main.yaml main.yaml
How to discard changes and reset file
git checkout main.yaml origin master
or
git checkout HEAD — main.yaml
Will update both the working copy of main.yaml and its state in the index with that from HEAD.
— basically means treat every argument after this point as a file name
2 thoughts on “Git Recap”
good
Thanks for the recap!