6. Git status, git log, git add, git commit -m, hashes, HEAD, statuses: untracked, modified, staged etc.
10. Use git commit --amend --no-edit or git commit --amend -m "new message" to edit the last commit(HEAD).
**13. git diff shows you the differences between modified; git diff --staged shows the differences btw in staged changes.
**14. Create .gitignore file to ignore some files or directories. It will not be tracked. And commit .gitignore before that **
15. To copy a remote repository use git clone + <SSH-key of the repository>. It connect a remote rep. and a local rep. automaticaly.
16. git branch shows you all branches. git branch <branch_name> to create a branch. git checkout <branch_name> to switch to a new branch.
17.git diff <branch_name> <anpther_branch_name> shows the difference btw these branches. Or use a hash instead of branch_name.
18. Use ~ to refer to the previous commits. For example: git diff main~3 main to compare the last commit(HEAD) in main branch and 4th commit from the end.
19. git merge <branch_name> to merge(join) two branches together. For deleting a branch use a command git branch -D <branch_name> or a lighter variant with flag -d.
21. To merge your branch with the main in GitHub use PULL REQUEST by the link while push it first time or use GitHub interface to pull request, review code, comment it and cancel or merge it with the main branch.
**23. If two branches are without conflicts and all commits may be put in one chain, these branches can be merged in fast-forward mode. You can turn the mode off using the flag --no-ff. **
24. git push --force can push your local branch to the remote one.WARNING: can be deleted some commits or the branch can be broken. Use it wisely.
**feature branch workflow - when every new feature or change is supposed to be in a new branch and can be merged in the main till completion. **
git flow - more complicated variant, created more branches and all commits are divided on different types: fix,feature etc. Different commits are located in different branches.
trunk-based - populat in big companies, it is similar to feature branch workflow. Participants often merge their code in the main. E.g every day.
graph LR;
untracked -- "git add" --> staged;
staged -- "???" --> tracked/comitted;
%% the arrow without any text for example:
A --> B;