Git is a tools for managing versions of directories between local and remote (cloud) locations. It is a version control system that can efficiently manage small to very large projects and is free and open-source. Git is a tool used to log source code changes, allowing several engineers to collaborate on non-linear development.

Any development project, including test automation, benefits from version control, often known as source control. It is the process of keeping track of and granting control over alterations made to source code. Let’s learn about some of the most often used Git commands since Git is one of the most widely used version control solutions.

Mastering Git takes time, however in this post you’ll discover key commands that are used more regularly.

To Install Git on your local computer download this from official site git:

[x] Git Download link

or

You Can simply download github desktop version GUI Operation

[x] Github GUI Download link

The Common steps are as follows:

  1. Workign Directory (mkdir/ Touch).
  2. Stage (Add).
  3. Repository (Commit).
  4. Remote (Push/ Pull).

Git Commands You Should Know

1. git config

Tell git who you are. In the beginning, you must configure the author name and email address which shall be used for committing your changes in the git directory.

  • The user.name and user.email are initially set up using the git config command. This details the login and email address that will be utilized from a local repository.
  • When the —global flag is used with git config, the settings are written to all of the computer’s repositories.
git config --global user.name "Jhon Doe"
git config --global user.email jhondoe@example.com

2. git init

This command is used to create a new repository on your local device

  • You shall provide your new repository name as well.

git init repositoryName

git init

3. git clone

With this command, the most recent version of a remote project is downloaded and copied to the specified place on the local computer.

  • If you want to download any repository to your local computer use this command.
git clone https://github.com/rafayethossain/rafayethossain.github.io.git

4. git status

This command lists all the files that have changed and those you still need to add or commit to your remote repository.

git status

5. git add

  • To stage changes of your current directory.
    git add.
    
  • To changes all the files except the deleted one.
git add \
  • To stage changes of all the files of specific extension.
git add \*.extension

  • To stage changes of all the files of specific extension.
git add \*.extension

  • To stage your root folder.
git add -all 

or

git add -A 

  • To stage changes of all the files of specific extension.
git add \*.extension

  • To stage changes of all the files of specific extension.
git add \*.extension

  • To stage changes of all the files of specific extension.
git add \*.extension

6. git commit

This command permanently stores a snapshot of the file in the version history. Commit does mean that changes are hosted to the remote repository

git commit -m "<commit message>"

8. git push

The next step is to send your changes to the remote server after committing your changes. Your commits are uploaded to the remote repository using git push.

git push

9. git pull

The remote repository’s updates are downloaded using the git pull command. This command combines git fetch and git merge, so when we use git pull, it downloads the most recent updates from a remote repository (git fetch) and quickly applies them to your local repository (git merge).

git pull

10. More helpful git command

  • git reset: to unstage your changes in your files.
  • git commit -m”write something here”: to commit your staged Changes.
  • git reset HEAD~: to unstage your committed changes.
  • git reset -hard: almost same to the git reset but it also gives you the deleted files.
  • git rm filename.extension: to delete and stage the changes in your file.
  • git rm filename.extension f: to delete the file forcefully which hasn’t been staged.
  • git rm –cached filename.extension: to stage the changes and not to delete the file from working directory.
  • git rm -r folder: to remove folder.
  • git branch:to check the current branch.
  • git branch branch-name to create a new branch.
  • git checkout branchName: to switch to a branch.
  • git merge branchName -m”write something”: to merge your branch with another branch.
  • ls: to see the list of your files.
  • Git push, fetch, pull: command to transfering data between remote and local directory.
  • git push origin branchName: to storing to specif cloud branck.
  • git fetch: to copy remote data to local
  • git pull: to clone all files to local directory from cloud.

CMD Command for Windows PC Terminal

  • touch filename.extension: to create a file.
  • mkdir foldername: to create a folder.
  • cd foldername: to enter a folder.
  • pwd: to check the directory currently you are working on.

Enjoy !!! See Yaaa, Next.

⬆ back to top



Buy me a coffee if you enjoyed this post. Your support helps me create more valuable content. Thank you!

"Buy Me A Coffee" "Buy Me A Coffee"



About Content Creator:

Hi, This is Rafayet Hossain

A Seasoned Business Systems Analyst, Project Manager, and SQA Engineer with experience in driving digital changes within organizations. I specialize in understanding business needs and developing software solutions to improve processes and drive growth. I am skilled in managing projects, analyzing data, and ensuring quality in the final product. I am passionate about using my expertise to help organizations reach their goals and succeed. Let’s work together to improve your business and drive success. Contact me for any inquiries or projects.

👉 For Any Query or Assignment Contact: :

Linkedin Gmail



Enjoy !!! See Yaaa, Next.

Cover