Summary of fundamental git concepts:
- repository: a collection of all commits and logs
- commit: a snapshot of the files at the time it was created
- branch: label for a commit and its subsequent commits
- master: the main branch
- HEAD: current commit
- origin: remote repository
- staging area: intermediate step before creating a commit
Summary of most frequently used commands in git:
# show current status
$ git status
# show commits in chronological order [with statistics]
$ git log [--stat]
# show branching graph between two branches [represented in single lines]
$ git log --graph [--oneline] branch1 branch2
# show difference between two commits
$ git diff commit1 commit2
# show difference between the specified commit and its direct parent
$ git show commit_hash
# load specified commit
$ git checkout commit_hash
# load specified branch
$ git checkout branch_name
# save current work as a new branch
$ git checkout -b new_branch_name
# show [hidden] branches
$ git branch [-a]
# create a new branch
$ git branch new_branch_name
# add branch2 into branch1; i.e., branch1 will incorporate branch2
$ git merge branch1 branch2
# add files to staging area
$ git add .
# remove files from staging area
$ git reset
No comments:
Post a Comment