Git is a DevOps tool (software) used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to tracking changes in the source code, enabling multiple developers to work together on non-linear development.
- global config (if we have single gitHub account)
- local config
- git config --global user.name "your_github_user_name"
- git config --global user.email "your_github_email"
- git config --list
- git clone gitHub_code_HTTPS_link
- ls
check list of Hidden files inside directory
- ls -Hidden
- git status
- modified - something changed inside existing files
- untracked - added new file that git doesn't yet track
- staged - file is ready to be committed
- unmodified - unchanged
- git add . (add all files)
- git add file_name (add single file)
- git commit -m "some message"
- git init
- git add .
- git commit -m "initial commit"
- git remote add origin gitHub_code_HTTPS_link
- git remote -v (to check remote origin)
- git branch (to check current branch)
- git branch -M branch_name (to rename branch)
- git push origin main | git push -u origin main
- Create a gitHub Repo
- Clone gitHub repo
- Make changes
- git add .
- git commit -m "some message"
- git push origin main
- git branch (check current branch)
- git branch -M main (Rename branch)
- git checkout -b new_branch_name (create new branch)
- git checkout branch_name (to navigate another branch)
- git branch -d branch_name (delete)
-
Way-1 git diff branch_name (to compare commits, branches, files & more) git merge branch_name (to merge)
-
Way-2 Create PR (Pull Request)
A pull request is a request to merge a branch into another branch on GitHub. It is a way to propose changes to a project without directly committing them.
It let's you tell others about changes you've pushed to a branch in a repository on GitHub.
- git pull origin main (to fetch and merge changes)
used to fetch and download content from a remote repo and immediately update the local rep to match that content.
An event that takes place when Git is unable to automatically resolve differences in code between two commits at the same place.
Manually by edit code.
Case 1 - staged changes (git add .)
- git reset file_name
- git reset (all files)
Case 2 - committed changes (for one commit)
- git reset HEAD~1
- git reset HEAD~n (for n commits)
Case 3 - committed changes (for many commits)
- git reset commit_hash_value
- git reset --hard commit_hash_value
- git log
A rough copy of a repository on GitHub. It is a way to create a new repository that is a copy of an existing repository.
First of all navigate to nested directory in vs code or any terminal like powershall or CLI
- PowerShell: Use Remove-Item -Path ".git" -Recurse -Force
- CMD: Use rd /S /Q "C:\path\to\repo"
- Git Bash or Unix-based shell: Use rm -rf /path/to/repo
After remove .git folder from nested repo navigate to parent directory using cd .. and run following command -
- git add .
- git commit -m "resolved nested repo issue"
- git push -u origin main