Author- Saptarshi Jana
git config --global user.name "SaptarshiJana07"
git config --global user.email "[email protected]"
git config --list
All files: Get-ChildItem -Force
, Only Hidden: Get-ChildItem -Force -Hidden
show files: ls {any one of cmd}
cmd: -Attributes, -Directory, -File, -Hidden, -ReadOnly,
-System.
Initiate git in the local repo: git init
clone the remote repo in local folder: git clone https://github.com/SaptarshiJana07/GitDemo.git
Create a GitHub repo >> clone it with the local folder {PS G:\Git_local\GitDemo> git clone https://github.com/SaptarshiJana07/GitDemo.git
} >> make changes >> Add all changes {PS G:\Git_local\GitDemo> git add .
} >> Commit them with message {PS G:\Git_local\GitDemo> git commit -m "message"
} >> Push it to the GitHub {PS G:\Git_local\GitDemo> git push -u oginin main
} >> If you have made some changes at remote repo the sync it with local repo{PS G:\Git_local\GitDemo> git pull oginin main
}
check the remote repo>> {git remote -v
}
PS G:\Git_local\GitDemo>
git status
== 1. Untracked 2. modified 3. Stagged 4. Unmodified
Output: "On branch main Your branch is up to date with 'origin/main'. othing to commit, working tree clean"
or On branch main---Nothing to commit Changes not staged for commit: modified: README.md (Sol: use 1. "git add" and/or 2. "git commit -a")
(Sol: use "git add ..." to stage (include/update) the changes, what will be committed) (Sol: use "git restore ..." to discard changes in working directory)
(Sol: use "git commit -a <some_message>" to record changes in working directory)
PS G:\Git_local\GitDemo>
git add .
check "git status"-- all stagged files will turn into green
PS G:\Git_local\GitDemo>
git commit -m "new file added"
PS G:\Git_local\GitDemo>
git push origin main
>> PS G:\Git_local\GitDemo>git push origin branch1
(in case of updating in the branch1 repo not the main)
git branch
create a new branch at the current commit
git branch [branch-name]
switch to another branch and check it out into your working directory
git checkout
merge the specified branch’s history into the current one
git merge [branch]
show all commits in the current branch’s history
git log
create branch: git branch -b person1
delete branch: git branch -d person1
(after checking out from that branch)
create branch: git branch -b person1