suudi4 / just-enough-git

Home Page:https://www.youtube.com/watch?v=wx3ultvbzUY&ab_channel=TomDoesTech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Just enough Git to be productive

Who is this for?

  • Those who are yet to land their first job in tech
  • Those who have recently landed their first job in tech

Notes

  • There are different Git workflows - Trunk, GitFlow, GitHubFlow
  • Git and GitHub are not the same thing - Going to be using
  • Going to use the command line & the GitHub VsCode extension

Assumptions

Terms

  • Branch - A version of the codebase
  • Commit - A unit of change
  • Stage
  • Merge - Combining two branches
  • Pull Request - A request to merge a branch into another branch

What is Git?

  • Git is a version control system
  • Allows you to track changes to your code over time
  • Enables you to collaborate with others on the same codebase
  • You can easily revert to a previous version of your code or experiment with new features without affecting the main codebase
  • Provides a record of all changes made to your code, including who made them and when, which can be useful for auditing and debugging

Common tasks you need to do with Git

  • How create a new repository?
  • How do I create a new branch?
  • How do I make changes on my branch?
  • How do I push my changes to GitHub?
  • How do I create a pull request?
  • How do I merge my changes into the main branch?
  • How do I check the status of my repository?
  • How do I manage conflicts?
  • How do I remove a file and make sure it's not tracked by Git?

Commands

  • git init - Initialize a new Git repository
  • git status - Show the status of the current branch
  • git add - Add a file to the staging area
  • git commit - Commit the staged files to the current branch
  • git log - Show the commit history of the current branch
  • git status - Show the status of the current branch
  • git branch - List the branches in the current repository
  • git checkout - Switch to a different branch
  • git pull - Pull the latest changes from the remote repository
  • git push - Push the latest changes to the remote repository

Pro tips

  • Use the GitHub VsCode extension

  • Commit early and commit often

  • Use semantic commit messages

  • Make small pull requests - single feature or bug fix

  • Use the GitHub pull request template

  • Write descriptive pull requests

  • Ask team about conflict resolution strategy - rebase or merge

  • Ask team about commit strategy - squash or merge

  • Ask team about workflow - trunk, gitflow, githubflow

  • git config --global push.autoSetupRemote true

Lear more