##Google Analz## ##Microsoft## ##Googel## Swanand: Here is a cheat sheet of common Git commands with examples

Saturday 14 October 2023

Here is a cheat sheet of common Git commands with examples

 Here is a cheat sheet of common Git commands with examples:

Git basics

  • git init: Initialize a new Git repository.
  • git add <file or directory>: Add a file or directory to the staging area.
  • git commit -m <message>: Commit the changes in the staging area to the repository with a commit message.
  • git push <remote> <branch>: Push the local branch to the remote repository.
  • git pull <remote> <branch>: Pull the remote branch to the local repository.
  • git status: Show the status of the working tree and staging area.
  • git diff: Show the changes between the working tree and the staging area, or between the staging area and the last commit.
  • git log: Show the history of commits in the repository.
  • git checkout <branch>: Switch to a different branch.

Git branching

  • git branch <branch name>: Create a new branch.
  • git checkout -b <branch name>: Create a new branch and switch to it.
  • git merge <branch name>: Merge the changes from another branch into the current branch.
  • git rebase <branch name>: Replay the commits from one branch onto another branch.
  • git branch -d <branch name>: Delete a branch.

Git collaboration

  • git clone <url>: Clone a remote repository to your local machine.
  • git fetch: Fetch the latest changes from the remote repository.
  • git merge <remote> <branch>: Merge the changes from the remote branch into the current branch.
  • git push <remote> <branch>: Push the local branch to the remote repository.

Example:

To initialize a new Git repository, run the following command:

git init

To add a file to the staging area, run the following command:

git add <file name>

To commit the changes in the staging area to the repository, run the following command:

git commit -m <commit message>

To push the local branch to the remote repository, run the following command:

git push <remote> <branch>

To pull the remote branch to the local repository, run the following command:

git pull <remote> <branch>

For more information on Git, please see the official Git documentation.

No comments:

Post a Comment

Featured post

Vicidial With WebRTC

Vicidial With WebRTC VICIDial is well known open source call center software. It has been in use by many small to large scaled con...