DEV Community

Discussion on: Git cheatsheet for beginners

Collapse
 
slavius profile image
Slavius

While this may be "very basic" introduction, it is confusing. Nothing is explained in detail on how things work and relate to each other.
After reading this article you might be able to manage a single repository of configuration files on your own computer, that's it. For a software developer part of a team this is simply not even a start.

In a company with a team of SW developers you:

  • use git flow to work on features and bugs with many branches like: features, develop, release, hotfixes in addition to master
  • amend commits to update it
  • work with remotes to fetch/push/pull your code
  • work with tags for versioning
  • use .gitignore to exclude files/folders from index
  • merge or rebase changes onto different branches while resolving conflicts in the process
  • as a maintainer merge or cherry-pick commits from pull requests
  • use submodules for dependencies and checkout recursively, committing to superproject as well
  • use pre- and post- hooks to integrate with CICD pipeline
  • stash/shelve push/pop to save uncommitted changes while switching branches
  • using bisect to find bugs
  • using blame to find changes/bugs
  • using git reset/clean to revert mistakes
  • etc., etc. Each of these operations changes in some way your local or remote repository or some of the refs or files in working tree or your index. Make a mistake and you either lose your important changes or overwrite someone else's code with its history making it disappear forever. (unless you're lucky and can extract commits using git's reflog).

I just named about 30 new terms you need to know how to use, know all of their command line parameters and be aware what changes they do to your refs, files, index, branch or repository.

Confused? No wonder. Git has so many commands, terms and parameters that you can generate random legit looking git man pages without noticing that they are nonsense jokes. Just have a look at this "Git random man page generator" git-man-page-generator.lokaltog.net/