Trang chủ Khám phá công nghệ Basic git commands for beginners

Basic git commands for beginners

2

In this article I will write about basic git commands for beginners.

What is git?

How git works
How git works

Git is the most popular version control system (VCS) in the world and it’s hard to imagine what a developer’s life would be like without it. Nowadays, the vast majority of developers – including individuals and large companies – choose Git for their projects.

Basic question, how to use git. In this article, I will help you

17 basic git commands

1. git –version

It shows the version of Git installed on your machine

2. git init

It will initialize the project folder into a “git repository”

3. git status

In simple terms, it will show your exactly which files/folders have been modified

4. git add .

It will add all your files to the git staging area. You can also add individual files to the staging area.

For example: git add "index.html"

5. git diff

It will show the difference between a file in the staging area and file that’s present in the working tree (untracked file)

6. git commit -m ‘msg’

It will save your changes in your local repository. It’s good practice to include proper commit message which helps in debugging

7. git push

It will push all the local changes that you have made to the remote github repository

8. git pull

It will pull (fetch) all the updated code from the remote branch and merge it with your local branch

9. git log

It will list down the entire commit history, all the commits that you have made till now

10. git branch <name>

This command is used to create a new branch in your local git repository

11. git branch

It will list down all the local branches that you have created

12. git branch -a

It will list down all the branches. Local branches + remote branches that’s available for checkout

13. git branch -D <name>

It will forcefully delete the specified local branch (even if the changes are not commited)

14. git checkout <branch_name>

It is used to switch between local git branches

15. git stash

It is used to temporarily remove the changes that you have made on the working tree

16. git remote

It will give the name of the remote repository

For example: “origin” or “upstream”

17. git remote -v

It will give the name as well as the url of the remote re pository.

Read more about Java: Java Programming

2 BÌNH LUẬN

BÌNH LUẬN

Vui lòng nhập bình luận của bạn
Vui lòng nhập tên của bạn ở đây

Exit mobile version