Git is a version control system which helps to control different versions of the project.Git is a tool.
GitHub is a service/website which allows to store and manage source code in a form of repositories.
- git --version : it shows the version of the git.
- git config: used to set the configuration values on the local or global level.
- git config --global user.name 'name': used to set the name of the person/organisation who is making a commit. (Note: global config is used for currently logged-in user and all repositories. And local config is used for specific repository.)
- git config --global user.email 'email id': used to set the email of the account for which we are going to make changes.
- git config --list : it shows the list of all git configurations.
- git clone <'link'> used to clone repository on local machine.
- git status : it display the state of code.
- git status : it display the state of code.
(NOTE: there are 4 types of status:
1. untracked:new files which are not tracked by git yet.
2. modified : changed
3. staged : file is ready to be comitted
4. unmodified :unchaged) - git add 'file name' : used to add new or changed files in working area to git staging area.
- git add . : used to add all new or changed files in working area to git staging area at once.
- git commit -m 'message' : it is a record of change.
- git push origin 'main (i.e) name of branch' : used to upload content from local repo to remote repo.
- git init : used to create new git repo.
- git remote add origin 'link' : used to add new repo to git .
- git remote -v :to verify remote
- git branch :to check branch
(A branch is a pointer to a specific commit. It is also known as a version of repository.) - git branch -M main :to rename branch. (master is a by default branch.)
- git push-u origin main : used to push code on same branch in future using 'git push' only
- git checkout 'branch name' :to navigate to another branch.
- git checkout -b 'new branch name :to create new branch.
- git branch -d 'branch name' :to delete branch.
- git diff 'branch name' :to compare commits , files, branch.
- git merge 'branch name' :to merge 2 branches.
- git rm --cached filename :used to remove the history of the tracked files.
- git pull origin 'branch name' :used to integrate remote changes/content on local repo .
- .gitignore :it contains the files which are ignored by the git during tracking, may be database files etc.
- pull request :It lets you tell others about changes you have pushed to a branch in repository on GitHUb and wish to merge them.
- git reset :to undo the all added files for commit.
- git reset 'filename' :to undo the added files or changes for commit.
- git reset Head~1 :to undo the latest commit only
- git reset 'commit hash' :to undo many commits.
- git reset --hard 'commit hash' :to undo many commits on both locally and remotely .
- git log :to undo check log file of all commits done on branch
- Resolving merge conflicts :An event that take place when Git is unable to automatically resolves differences in code between two commits. There are two ways : 1. Pull request method 2. merge command
- fork : is used to make a rough copy of existing repository.