Welcome to the foundation of Git. These are the everyday commands you will use to track your code, stage changes, and create commits.
Creates a new, empty Git repository or reinitializes an existing one. #start #new #setup
git initStages every modified, deleted, and untracked file in the current directory. #add-all #track
git add .Before a change can be committed, it must be staged. This interactive command queries your working directory for any modified or untracked files and allows you to select exactly which one you want to stage. #stage
git add $fileA commit records a snapshot of your staged changes. Good commit messages are critical for maintaining a readable history. This command also optionally signs your commit with GPG if you need verifiable history for security compliance. #save #snapshot
git commit $opts -m "$message"Modify the most recent commit. This replaces the old commit with a new one. You can edit the commit message or use --no-edit to just add newly staged files to the previous commit. #rename-commit #edit-message #oops #fix
git commit --amend $no_editgit restore --staged $file_stagedgit restore --staged .If you've made a mistake and want to revert a file back to exactly how it looks in your last commit, use this command. Be careful: this is a destructive action and cannot be easily undone. #revert-file #checkout-file #undo-file
git restore $file_restoreSometimes you need to switch contexts (like checking out a different branch) but you aren't ready to commit your current work. Stashing allows you to save your messy state on a stack so you can retrieve it later. #save-work #shelve #hide #pause
git stash push $include_untracked -m "$message"Once you are ready to resume the work you stashed away, use stash pop. This will apply the changes from the stash to your current working directory and remove the stash from the stack. #restore-work #unshelve #resume
git stash pop $stashgit restore .