git config --global user.name "<username>"
git config --global user.email "<email>"
git log
git --version
git init
git status
git rm --cached <file_name>
git rm --cached index.html
git add index.html => For add the index.html to the staging area
git add . => For adding all untracked files to staging area
git add *.html => For adding all html files to staging area
git push -u <remote_name> <branch_name>
git push -u origin <branch_name>
The remote name is a short-hand label for a remote repository.
origin
is the conventional default name for the first remote and is usually where you push to when you don't specify a remote for git. You can set up more than one remote for your local repo and you use the remote name when pushing to them.
git checkout <branch_name> => For switching branch
git checkout -b <branch_name> => For creating new branch
git merge <branch_name>
git branch -d <branch_name> => For deleting local branch
git push -d <remote_name> <branch_name> => For deleting remote branch
In most cases the remote name is origin.
"-d" can also be written as "--delete", "-D"
Git sees every file in your working copy as one of three things:
- Tracked - a file which has been previously staged or committed.
- Untracked - a file which has not been staged or committed.
- Ignored - a file which Git has been explicitly told to ignore.
touch .gitignore
If we want something that should not be staged while adding to git, it can be done with the help of gitignore
- If we don't want file named "index.hml" to be staged, add this in the gitignore file.
index.html
- If we don't want folder named "secretFolder" to be staged, add this in the gitignore file.
/secretFolder
- If we don't want html files to be staged, add this in the gitignore file.
*.html
git clone <url>
cd <repo_name>
git fetch
git checkout <branch_name>
repo is a short form of repository
git init
git config --global user.name "<username>"
git config --global user.email "<email>"
git remote add origin <repo_url>
git add .
git commit -m "commit message goes here"
git push -u origin master
git add .
git commit -m "commit message goes here"
git checkout -b <branch_name>
git push -u origin <branch_name>