Git Basics
Git Basics
Learning how to create a stable repository so it does not crash when having multiple branches for a project
la
Short-hand form of ls -la
Shows all the files including hidden ones
.git is a folder that stores all the commits and changes in the history of the repository
git status
shows updates that haven’t been saved
git add .
stages all untracked and updated files
git commit -m "meaningful messages"
please include the what and why you committed
git push
post this git live on a remote repository where my project is hosted
ssh-keygen -t rsa -b 4096 -C "jyu673@gatech.edu"
Generates a ssh key
ls | grep <name of the key>
Helps to get the key
cat <name of the key>.pub
git init
Initialize empty git repository in this current directory
git remote add origin <ssh-link>
git remote -v
git push -u origin master
Adds reference to remote repository
Checking any remote repositories connected to the current one
Makes the default upstream to push (which is origin)
git branch
Looks at different branches
git checkout -b <name of branch>
Makes a new branch
git diff <branch>
Looks at the changes that have been made when compared to
git pull origin master
Fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out
git branch -d <name of branch>
Deletes branch
git commit -am 'message'
Works with modified files
Stash –> temporary holding place
git merge <name of branch>
Merges with the <name of branch
git reset
Unstaging (undo add)
git reset HEAD~1
Undo commit
git add -p <filename>
Patch level git
How to deal with merge conflicts: merge, rebase, pull, cherry-pick, stash apply …