Learn Git using Git Repository
A simple ways to understand Git Basic Commands
Why using version control ?
- collaborate !
- a better professional
- allow you to revert back
- compare changes
- easy recover and track
main target : understand basic git command
- git init
- git config --global user.name "yunanhelmy"
- git config --global user.email "email@example.com"
- git remote add origin firstname.lastname@example.org:yunanhelmy/learn-git.git
- git remote remove origin
- git status
- git add -A
- git commit -m "this is my comment"
- git push origin master
- git pull origin master
- git diff HEAD
- git checkout index.html
- git stash
- git reset HEAD~1
- git revert HEAD~1
i can see every your move !
- separate your short-lived branch and long-lived branch
- use short-lived branch for every issue you had
- periodically delete your short-lived branch
- don't push your short-lived branch to the remote repository, unless you want to share the code to other developers
- name your long-lived branch clearly and understandable, eg production, staging, live, development
- name your short-lived branch with prefix (if you don't have issue number / ticket number). this will make you easy to remember when you have a lot of short-lived branch
- create another master backup if you are unsure when you want to merge. test it in that backup before going to master. don't forget to delete your junk branch
- use revert instead reset unless you want completely remove commit history
- be aware with rebase. one failure can be a fatal. rebasing will completely override code. that means you lost the changes in the same file
Thats it the basic you need to know