6  Git Commands

6.1 git - best practices

pull - work - commit - pull - push

  • git pull
  • Make changes
  • git commit your changes to your local repository
  • git pull the latest remote changes to your local repository
  • git push your changes.

Pay attention to any error messages.

6.2 Outline of essential Git commands

Here’s an outline of essential Git commands, initially created by ChatGPT:

6.2.1 Initialization and Configuration

  • git init: Initializes a new Git repository in the current directory.
  • git config: Configure Git settings.

6.2.2 Basic Workflow

  • git add: Stage changes.
  • git commit -m "message": Commits staged changes with a descriptive message.

6.2.3 Remote Repositories

  • git clone: Clones a remote repository to your local machine.
  • git push: Send local changes to remote repository.
  • git pull: Retrieve changes from remote.
  • git remote: Manage remote repositories.

6.2.4 Status and Changes

  • git status: Shows the current state of your working directory.
  • git diff: Displays changes between working directory and the last commit.

6.2.5 History and Logs

  • git log: View commit history.
  • git log --oneline: Compact commit history.

6.2.6 Ignoring Files

  • Create .gitignore file.

6.2.7 Branching

  • git branch: List/create branches.
  • git checkout: Switch branches.
  • git merge: Merge branches.

6.2.8 Undoing Changes

  • git reset: Unstage or reset changes.
  • git revert: Create undoing commits.

6.2.9 Tagging

  • git tag: Create and manage tags.

6.2.10 Stashing

  • git stash: Temporarily store changes.