important git commands you should know


Version control also known as source control is the ability to save changes made to files. when changes are made locally, they are committed and then send the repository within git. other developers can clone or pull and from the repository to get the update changes.

Here is a list of git basic commands to get you started.

1) git config

Action:  To set the username and email in the configuration file.
Usage: To check your credentials enter the following commands
git config --global user.email
to set your email or username run the below commands
git config --global email="swagasoft@gmail.com"
git config --global username="swagasoft"

2) git init

Action: to initialize a git repository for a new or existing project.
Usage: run the following command in the root of the directory of your project.
git init

3) git clone

Action: Copy a git repository from a remote source.
Usage: The following code will clone an existing project from the repository to the local directory.
git clone <git url>

4) git status

Action: To check the status of files you have made changes to.
usage: List all files that have changed in your working directory.
git status

5) git add

Action: Add changes to stage in your working directory
Usage: you can add a specific file by specifying the file name after this command, but it is better you use the below command to add every changed file in your working directory.
git add.

6) git commit

Action: Commit your changes and set it to a new commit object for your remote.
git commit -m "my first commit"

7) git push

Action: push your changes to the remote repository.
if you have committed your changes then you should push them with the following command.
git push 

9) git pull

Action: pull the update changes from the remote repository.
if your remote has updated changes pull them using the following command.
git pull 

10) git branch

Action: Check your current branch
git branch

11) git branch -a

Action: list all available branch
git branch -a

12) git stash

Action: save changes hat you do not want to commit immediately. 
git stash apply if you want to bring your save changes back
git stash

13) git merge

Action: merge two branches you were working on. 
git merge <branch to merge>

13) git remote

Action:  check what remote or source you have or add a new remote.
git remote

Post a comment

0 Comments