Skip to main content

Git Installation Guide

This guide provides all the key information and getting-started instructions after a successful Git installation via DeploySage-CLI.

Initial Configuration

Before you start using Git, it is essential to set your user name and email address. This information is used in every commit you create.

# Set your user name
git config --global user.name "Your Name"

# Set your email address
git config --global user.email "[email protected]"

# (Optional) Set the default branch name to 'main'
git config --global init.defaultBranch main

Basic Workflow

Branch Management

The most common Git workflow involves creating or cloning a repository and then staging, committing, and pushing changes.

Branches are a core feature of Git, allowing you to work on different features in isolation.

# Initialize a new repository
git init my_project

# Or clone an existing repository
git clone https://github.com/example/repo.git

# Check the status of your changes
git status

# Add files to the staging area
git add .

# Commit your staged changes
git commit -m "Add initial files"

# Push changes to the remote repository
git push
# List all local branches
git branch

# Create a new branch
git branch new-feature

# Switch to the new branch
git checkout new-feature

# Or create and switch in one command
git checkout -b another-feature

# Merge the branch into your current branch
git merge new-feature

Working with Remotes

Remotes are versions of your repository that live on other servers.

# List your remote connections
git remote -v

# Add a new remote repository
git remote add origin https://github.com/user/repo.git

# Fetch changes from a remote
git fetch origin

# Pull changes from a remote
git pull origin main