Table of Contents
Basic Git commands
git config –global user.name “[firstname lastname]”
This command sets the firstname and lastname. Whatever you set will be visible in the commit history.
git config –global user.email “[valid-email]”
This command sets the emailid, and this will be visible in the commit history.
git init
This is used initialize an empty GIT repository.
git clone [repourl]
This will clone the entire repository from the repository url specified.
Git commands post changes
git status
To view the changes or the untracked files in the project that has not been saved yet.
git add [file]
Whenever you add a new file to GIT, you have to stage it first. Below example either adds a single file or all files.
Example: git add fileName OR git add .
git commit -m “[commit message to identify later]”
Once your files are staged, this command will commit the files.
git log
this command is used to view the history of the project which shows the Commit Id, Author, Date and commit message.
git branch
List all the branches.
git branch [new branch name]
This command will create a new branch.
git checkout
This command will switch to another branch and checkout into your working directory.
git push [alias] [branch]
Push the changes done on local repository to remote repository.
git pull
This command fetches and merges changes from the remote server to your working directory.
Project Sharing
git remote add [alias] [url]
To connect your remote repository to to Local repository.
Example:- git remote add origin your_git_url
git remote -v
To view all the remote urls out there.
Leave a Reply