Table of contents
GitHub Basic Commands
git config:
This command sets the author name and email address respectively to be used with your commits.
git config –global user.name “[name]”
git config –global user.email “[email address]”
git init:
This command is used to initialize a new repository.
git init <"path_name">
git clone:
This command is used to obtain a repository from a remote server to your local server.
git clone <"repository_link">
git add:
This command adds a file to the staging area.
git add . # for adding all the files in the staging area
git add <"file_name"> # for adding only selected files in the repo
git commit:
This command records or snapshots the file permanently in the version history.
git commit -m "any_message"
git branch:
The git branch command is used to determine what branch the local repository is on.
git branch <"branch_name"> # Create a new branch
git branch -a # List all remote or local branch names
git branch -d <"branch_name"> # To delete a branch
git pull:
The git pull command is used to fetch and merge changes from the remote repository to the local repository.
git pull <"branch_name"> <"repo_url">
git push:
The command git push is used to transfer the commits or push the content from the local repository to the remote repository.
git push -u origin <"branch_name">
git status:
The status command is used to display the state of the working directory and the staging area.
git status
Creating a new GitHub Repository
Log in to your GitHub account on GitHub
Click on New
Enter your new repository name and check all the configurations whether you want to keep your repository private or public.
After adding all the configurations click on Create Repository. The default branch will be the main branch.
The new repository with the name "Practice", description "For Hashnode" and the default branch "main" with a README.md file has been created.