/    /  Git – Basic Command

Git Commands 

 

Here are some of the basic Git commands that you’ll use frequently:

  • git init – This command initializes a new Git repository in the current directory.
  • git clone <repository-url> – This command clones an existing Git repository from a remote source to your local machine.
  • git add <file> – This command stages a file for a commit. You can stage multiple files at once or use git add . to stage all modified and new files.
  • git commit -m “<message>” – This command creates a new commit with the staged changes and adds a message to describe the changes.
  • git status – This command shows the current status of the Git repository, including the branch you’re on and any modified or staged files.
  • git log – This command displays a list of all the commits in the current branch.
  • git diff – This command shows the difference between the current version of the code and the last committed version.
  • git branch – This command lists all the branches in the repository.
  • git checkout <branch-name> – This command switches to the specified branch.
  • git merge <branch-name> – This command merges changes from the specified branch into the current branch.
  • git pull – This command updates the current branch with changes from the remote repository.
  • git push <remote> <branch> – This command uploads the local changes in a branch to the remote repository.

These are just a few of the basic Git commands, and there are many more advanced commands and features available. The best way to learn Git is to start using it for your projects and to seek out additional resources as needed.

Here are some advanced Git commands that you might find useful:

  • git stash – This command temporarily saves changes that have not been committed. You can later reapply the stashed changes.
  • git rebase – This command modifies the existing commit history by reapplying the changes in the current branch on top of a different branch or commit.
  • git cherry-pick – This command applies a specific commit from one branch to another branch.
  • git reset – This command undoes commits, either by discarding all changes or by un-doing specific commits.
  • git tag – This command adds a tag to the current commit, which can be used to mark important milestones in the development of a project.
  • git bisect – This command is used to find the commit that introduced a bug by dividing the history into smaller and smaller chunks.
  • git submodule – This command allows you to include another Git repository within your Git repository.
  • git worktree – This command allows you to have multiple checkout of the same branch in different directories.
  • git blame – This command shows who made changes to each line of code in a file and when those changes were made.
  • git reflog – This command displays a list of all the changes to the branch pointers, even if those changes have been later discarded.

These are some of the more advanced Git commands, but there are still many more features available. It’s important to understand the basics of Git before attempting to use advanced commands, as they can have unintended consequences if used incorrectly.