Skip to content

Omcodes23/Git-Commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Git Commands

This README file provides a quick reference guide to some essential Git commands for version control. Whether you're a beginner or an experienced developer, these commands will help you manage your Git repositories effectively. Make sure you have Git installed on your system before using these commands.

Table of Contents

Git Configuration

Before using Git, it's essential to configure your name and email address:

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

Creating a New Repository

To create a new Git repository:

git init

Cloning a Repository

To clone an existing repository from a remote URL:

git clone <repository_url>

Adding and Committing Changes

  1. To stage changes for commit:
git add <filename>   # Stage a specific file
git add .            # Stage all changes
  1. To commit staged changes:
git commit -m "Your commit message"

Branching

  1. Create a new branch:
git branch <branch_name>
  1. Switch to a branch:
git checkout <branch_name>
  1. Create a new branch and switch to it:
git checkout -b <new_branch_name>

Merging

  1. Merge changes from one branch into the current branch:
git merge <branch_name>

Remote Repositories

  1. Add a remote repository:
git remote add <remote_name> <repository_url>
  1. Push changes to a remote repository:
git push <remote_name> <branch_name>
  1. Pull changes from a remote repository:
git pull <remote_name> <branch_name>

Undoing Changes

  1. Discard changes in a file:
git checkout -- <filename>
  1. Unstage changes:
git reset
  1. Amend the last commit (use with caution):
git commit --amend -m "New commit message"

Viewing Information

  1. View the status of your repository:
git status
  1. View the commit history:
git log
  1. View a list of branches:
git branch
  1. View changes made in a specific commit:
git show <commit_hash>

These are some of the most commonly used Git commands. Explore Git's documentation for more advanced features and options. Don't forget to commit your work regularly and write clear and concise commit messages to maintain a clean and organized version history. Happy coding!

About

This is a short list of all git commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published