- make sure you have git installed or download-here
- Get started with Git Bash
- Git will create a folder in C disk C:/Users/user/dirname
mkdir directoryname
- Git will initialise the directory in C disk C:/Users/user/dirname/.git/
- initializes a new Git repository and begins tracking an existing directory. It adds a hidden subfolder within the existing directory that houses the internal data structure required for version control
git init
- Typing following command files will be moved to staging area
git add filename
- We will know changes in form of description effected after each save of the specific document
git diff filename
- We will get to know various changes that we made to our whole project
git status
- Entering below command will save the doc files will fall into local repository
git commit -a -m 'the message we want here to be displayed here'
⚠️ Create an repositories and have its https link copied before moving ahead like the following one ⚠️
echo "# gittest" >> README.md
git push -u origin main
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/kiranbakale/gittest.git
- If we type in command it will be connected to remote repository
git remote add repo or aliasname repo url
git branch -M main
- Git will push our docs in local repo to master branch in remote repo
git push -u origin main
- Git helps developers use this command if at all made commits to a branch on a remote-repo, and they would like to reflect those changes in their local environment
git pull aliasname branch
- Git will create a different branch
git branch branchname
- Helps to switch to a different branch
git checkout branchname
- Git will integrate/merge two different branches
git merge branchname
Git clone is a command for downloading existing source code from a remote repository (like Github, for example). Git clone basically makes an identical copy of the latest version of a project in a repository and saves it to your computer.
git clone -b <Branch name><Repository URL>
git restore --staged filename
- History of the commits
git logs
- To jumping to specific commit and deleting the older
git reset commit-hash-id
- HEAD is a pointer that will point to current working branch and also say in which branch, the latest commits will be pushed.
unstaging a commit that is already being pushed to remote repo
git reset below-commit-log-id
git add .
git stash
git push origin kk -f
fetching commits from upstream repo and keeping our repo insync with upstream repo
git fetch --all --prune
git reset --hard upstream
git push origin main
squashing the commits
git rebase -i commit-hash
- upstream is the parent repo
- Any new thing you are working on create a new branch in local start working from there
- 1 pull req = 1 branch
- If you want to push newly created remote repo, then command
git push origin branchname
- A tool pops up and highlights problems causing the conflicts
git mergetool
For exiting the tool
- After successful changes type in following command to exit
:wq