Learning Git and GitHub with Harry on his YouTube channel CodeWithHarry.
clear
logout or exit
git config --global user.name
git config --global user.name Zulfequar Ali
git config --global user.email
git config --global user.email develperzull@gmail.com
code .
git init
ls -lart
ls
touch index.html
git status
git status -s
git add index.html
git add index.html about.html
git add --all or git add -A or git add .
git commit -m "Feature: Added a nav bar"
git checkout index.html
git checkout -f or git checkout --force
git log
git log -p -1 Hint: Press 'q' for quitting.
git log -1 or git log -n 1 or git log --max-count=1
git diff
git diff --staged
git commit -a -m "Feature: Added new files and directly commited without staging."
git rm waste.html
27. Move a staged or committed file to untracked area (file is first moved to staging area then deleted from there and moved to untracked area):
git rm --cached waste.html
Create '.gitignore' file in the root directory of the repository and list out the filenames to be ignored. Add '*.log' to the list to ingore all files with .log extension. Add '<directory_name>/' to the list to ingnore the directory and its contents. Add '<file_path>' to the list ingore a file at a specific folder.
git branch
git branch <branch_name>
git checkout <branch_name>
git checkout -b <branch_name>
git merge <branch_name>
git branch -d <branch_name> or git branch -D <branch_name>
git remote add <remote_name> <repository_url>
git remote
git remote -v or git remote -verbose
git push <remote_name> <branch_name>
ssh-keygen -t ed25519 -C "your_email@example.com" or ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519 [Note: If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.] or ssh-add <ssh_key_file_address> or ssh-add <local_repository_root_directory_address/ssh_key_filename>
clip < ~/.ssh/id_ed25519.pub or clip < <ssh_public_key_file_address>
cat ~/.ssh/id_ed25519.pub or cat <ssh_public_key_file_address>
ssh -T git@github.comYou may see a warning like this: > The authenticity of host 'github.com (IP ADDRESS)' can't be established. > RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. > Are you sure you want to continue connecting (yes/no)?
Verify that the fingerprint in the message you see matches GitHub's public key fingerprint. If it does, then type yes: > Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
Verify that the resulting message contains your username.
git remote get-url <remote_name> or git remote get-url --all <remote_name>
git remote set-url <remote_name> <new_url>
47. Update the remote by pushing/uploading the local files of a branch and add the upstream (tracking) reference as well:
git push -u <remote_name> <branch_name> or git push --set-upstream <remote_name> <branch_name>
48. Update the remote by pushing local files from the current branch (last pushed branch using -u or --set-upstream option):
git push
git clone <repository_url>
git clone <repository_url> <new_dictory_name>
git fetch origin git reset --hard origin/master