Git Commands Every Developer Should Know

Git Commands Every Developer Should Know

git.png

In this Article, i would like to list it out Git commands often used by the Developers. So Let's get Started :

1) git init : This command is used to initialize a project as a git repository or Create a local Git empty Repository.

2) git status : This command is used to view the status of your working tree & it helps us to see all the files which are untracked by git.

image.png

3) git commit : This command is used to commit staged files.

command ---> git commit -m<"commit message" >

4) git remote: This command is used to view the connected remote repositories

5) git push : This command is used to Push the committed files to remote repo. Remote repo aka Git hub

command ---> git push -u origin master

6)git log: This command displays a record of the commits in a Git repository.

7) git pull: This command fetches the required information,not only to local repo but also to current working directory.

command ---> git pull

8) git fetch: This command fetches required information to the local repo. it checks for new files,new branches etc.

command ---> git fetch

9) git branch: This command is used to preview the current branch you're working in.

git branch --> this command is used to create new branch in local repo.

10) git merge:

This command is used to incorporate new commits into feature branch. it creates an extra merge- commit every time to incorporate changes.

pre & post merge process is shown in the below image. {image source : internet}

image.png

11) git Rebase:

This command incorporates all new commits to master branch. re-writes project history by creating new commits, for each commits in original branch.

Please find the image below. {img source- internet}

image.png

12) git clone

Creates copy of existing git repo. it is used to get copy of remote repo to local repo.

13) git clean

This command used to delete untracked files & directories in our local repo.

git clean -f --> this is used to delete untracked files in our local repo.

git clean -d --> this is used to delete untracked directories in our local repo.

14) git reset:

This command will erase all the changes made in local repo & update it to the latest, version that was committed in remote repo.

15) git stash:

This command temporarily saves changes made to working copy & so we can work on something else & re-apply them later on. or sometimes we don't want to commit our code, but we also do not want to lose our unfinished code. in this case we use stash command record current state of our working directory.


Conclusion :

Thanks for reading

This are most used Git commands by Developers, Hope this commands post will be Helpful.

will be posting more regarding DevOps image.png