A repo about git tutorial. It contains essential git commands with both local machine and remote server
git init .
-> initialize a local working directorygit add .
-> add to staging areagit commit -m "message"
-> commit to history (includes a bunch of commit)
An online platform to host and collaborate on git repos
git push
-> push changes to themain
branch in remote servergit pull remote-name
-> pull new changes from remote server (ex. remote-name = origin)
git diff
-> show the current differencegit status
-> check working directory statusgit log --oneline
-> see history(past commits)git show history-id
-> show the changes from that commit
A branch represent an independent line of development
git branch -a
-> show a list of branches in the repogit checkout -b branch-name
-> create new branch and move to that branchgit branch -d branch-name
-> delete that branchgit checkout branch-name
-> change to the that branchgit checkout -
-> change back to the previous branch
Rebasing is the process of moving or combining a sequence of commits to a new base commit. Rebasing is most useful and easily visualized in the context of a feature branching workflow.
- Put local changes aside
- Merge current base and new changes from remote server together
- Add local changes on the top.
git pull -r origin main
-> pull and rebasegit push -f
-> force push