Git Command-Line Reference Guide This guide covers essential Git commands for managing your projects. Setting Up and Initializing git init What it does: Initializes a new local Git repository in the current directory. This creates the hidden .git folder. git clone [url] What it does: Creates a local copy of a remote repository. This is what you'll use to get a fresh copy of your Gitea repository. Making and Saving Changes git status What it does: Shows the status of your working directory. It tells you which files are staged, unstaged, or untracked. git add [file] What it does: Stages a file, preparing it to be committed. Use git add . to stage all modified files in the current directory. git commit -m "[message]" What it does: Saves the staged changes to your local repository history. The -m flag allows you to write a brief, descriptive message for your commit. git commit --amend What it does: Amends the most recent commit. This is useful for fixing a typo in your commit message or adding a file you forgot to stage. Working with the Remote Repository git remote -v What it does: Lists the remote repositories you've configured. This is useful for confirming that your local repository is connected to the correct Gitea URL. git remote set-url origin [new-url] What it does: Changes the URL for a remote repository. You would use this command to change the remote from GitHub to your Gitea instance. git push What it does: Pushes your committed local changes to the remote repository. Use git push -u origin main the first time you push to a new remote to set the upstream branch. git pull What it does: Fetches and downloads content from the remote repository and immediately integrates (merges) it into your local branch. git fetch What it does: Downloads new data from a remote repository but doesn't integrate it into your working files. This lets you review changes before merging. Managing Branches git branch What it does: Lists all local branches in your repository. git branch [branch-name] What it does: Creates a new local branch. git checkout [branch-name] What it does: Switches to an existing branch. Use git checkout -b [new-branch] to create and switch to a new branch in one command. git merge [branch-name] What it does: Merges the specified branch's history into your current branch. git branch -d [branch-name] What it does: Deletes the local branch.