Github

Title Code
Command
1st create a folder for git on pc
Basic configration...

$ git init	create .git file 
$ git --version
$ git config --global user.name "Aslam"
$ git config --global user.email "aslam@gmail.com"
$ git config --list
clear

Each of every project user & email
$ git config user.name "aslam"
$ git config user.email "aslam@gmail.com"


upload file...
$ git status
$ git add file.txt	[save this file]
$ git add --all	 or
$ git add .
$ git commit -m "message"
$ git remote add origin https...
$ git push -u origin master 

download file...
git status
git log
first create a folder...
git clone https link...

update.....
git status
git add .
git commit -m "message"
git log
git pull	
git push	[upload to master branch]

log 	[list of commit]
$ git log
$ git log --oneline

download from branch
create a branch first in git hub...

git clone https link...  -b branchName
branchName= about, help, contact etc
command2
switch go any repository or branch
git checkout  a1b2c3

How to switch back to 'master' with git?

git stash or git commit -m "abcd"
git checkout master
git branch -D merchantApi

Note: Above steps will delete the branch locally.

For deleting the branch you have to stash
 the changes made on the branch 
or you need to commit the changes
 you made on the branch. 
Follow the below steps if you made
 any changes in the current branch.
Github delete last commit
2nd commit : 2020
1st commit : 1010
---------------------
git reset --hard 1010
git push --force
Git check user
Local check
git config user.name
git config user.email
-----------------------
Global check
git config --global user.name
git config --global user.email
-----------------------
Change local
git config user.name "gitHub-UserName"
git config user.email "gitHub-email"
-----------------------
Change global
git config --global user.name "gitHub-UserName"
git config --global user.email "gitHub-email"
git info
github set project url
	->git remote set-url origin [repository link]
	
	example: https://github.com/aslamcsebd/project.git

github show project url
	->git remote show origin

https://mhagemann.medium.com/how-to-fix-ssh-permission-denied-with-git-clone-f669b65f90ac
Rename last commit
git commit --amend -m "New commit message"
git move other commit
git fetch origin [commit no]
git checkout FETCH_HEAD
Undo Git Pull
git reset commitNumber --hard
Git Uncommit
git reset --soft HEAD~1
git project url change
git remote set-url origin https://github.com/projectName.git
git push -u origin main
git branch
create branch
=> git branch anyName

edit branch
You edit branch which branch you stay
=> git branch -m newName

delete branch
You don't delete this branch which branch you stay now.
=> git branch -d branchName

Switch any branch
=> git checkout branchName

branch status see
=> git branch

->dev
->*main

[(* icon) means you are now stay main branch]


N:B: You are now [main branch] and you have 3 commit. when you create [dev branch] the main branch's all commit copy from main to dev branch.
So you should work now dev branch and when you have 5 commit you can merger the main branch.

But if you want to dev branch merge, you stay now main branch and pull/copy code from dev branch.

=> git merge dev


git merge: if you are now main branch with no code or commit, but want to merge/copy from another/dev branch.

In locally pc
-------------
git merge origin dev --allow-unrelated-histories


from server/cloud
-----------------
git pull origin masterOrDev --allow-unrelated-histories


N:B: if you want default main branch to dev, it working in the github server. There are many option to rename, default any branch as root/main branch.
How to reset your Git Settings
git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper
cmdkey /delete:LegacyGeneric:target=git:https://github.com
git config --global user.name “username”
git config --global user.email emailaddr
git config  credential.helper ‘store’
git remote add origin repolink
git remote -v
git init 
git add .   (Stage)
git commit -m “message”  (Commit)
git push origin master  (Push)


https://www.youtube.com/watch?v=HGfT8JFkC2I
git reset last work and move last commit
git reset --hard