# Delete the remote branch (will not delete the local branch) # Note: you don't need to prefix it with `/origin` because you already specified origin after the `push` option git push origin --delete myBranchName # Delete the local branch git branch -d myBranchName
gh auth login
Step 1: Generate a ssh-key value pair i.e, private and public key. Refer my own notes: Click here
Step 2: First add your public key to github account you want access to.
Step 3: Then add entry correspondingly like below to your
~/.ssh/config file -
HOST github.com HostName github.com IdentityFile "C:\Users\Array\Documents\ssh-keys\sahil-account-1-private-key" HOST github.com-sahilrajput03 HostName github.com IdentityFile "C:\Users\Array\Documents\ssh-keys\sahil-account-2-private-key"
Step 4: (Optional: May not be needed for ArchLinux) You might want to run command
ssh-add ~/.ssh/oanhnn_private_key if you are doing this on ubuntu (tested no Samaksh Ubuntu). Source: Click here
Step 5: Testing ssh connections:
ssh -T firstname.lastname@example.org # OUTPUT: Hi <username_here>! You've successfully authenticated, but GitHub does not provide shell access. ssh -T email@example.com # OUTPUT: Hi <username_here>! You've successfully authenticated, but GitHub does not provide shell access. # For Bitbucket ssh -T firstname.lastname@example.org # OUTPUT: authenticated via ssh key. # OUTPUT: You can use git to connect to Bitbucket. Shell access is disabled # For GitLab ssh -T email@example.com
Step 6: In your other than default account you can use below commadn to change name and email as well:
git config user.email "firstname.lastname@example.org" git config user.name "Super Man"
Source: Click here
git config --global log.date local
# Get current branch name git branch --show-current # Get current branch and its tracking branch (upstream branch) git branch -vv --contains # Update tracking branch for current branch git branch -u origin/$(git branch --show-current)
This error generally happens when we copy git repositories from a portable hard disk.
To fix this you can run command:
sudo chown -R array: test. Here we are marking the owner and group-owner of
test directory (including all its nested files/folder using option
To get lines added and lines deleted per file we can use
git diff a73c6a44ba HEAD --numstat # NOTE: ^^ Above command shows changes made after `a73c6a44ba` till current HEAD. (i.e, it doesn't include changes made in `a73c6a44ba` commit becoz thats how `git diff SHA1 SHA2` command works). # NOTE: Also, git diff a73c6a44ba (this command shows changes made after commit `a73c6a44ba` till HEAD becoz thats how `git diff SHA` command works. # OUTPUT (first number is added lines and second number is deleted lines: 7 0 src/components/layout/main-site-wrapper/authenticated/AuthenticatedPageWrapper.tsx 11 1 src/components/ui/ReportModal.tsx 14 2 src/components/ui/post/PostDetail.tsx
Similarly to get complete info for all flies we can use
git diff a73c6a44ba HEAD --shortstat # OUTPUT: 14 files changed, 89 insertions(+), 40 deletions(-)
To view for a very old for single commit you can use:
git show SHA --shortstat git show SHA --numstat
git config --global user.name "Sahil Rajput" git config --global user.email "email@example.com"
git --no-pager log git --no-pager show <commit_hash>
Also, the best way is simply set pager to
cat, life is amazing now! (source)
# File: ~/.gitconfig [core] pager = cat
You can use
git config --global core.pager "cat" to set
cat as pager for git log.
git branch: Prints all branches and * indicated is the current branch.
git branch test : will make
test named branch.
git branch somebranch SourceBranchHere will make
somebranch named branch.
git checkout branchName
git pull originvs.
git pull origin main
SD-499which was checked out from main.
git pull origin, this will only fetch and merge all remote branches to their respective local branches which set set t to tracked.
mainbranch into your current branch either by doing
git merge mainor you can do it by
git pull origin mainas both will do same thing. Why? Ans. Because
git pull origin mainwill pull update local main branch first and second it will merge
mainbranch to your
currently checkout branch. BECAUSE
git merge branch. Source: Atlassian, Git-scm
That can work actually.
.gitfolder any where
Yes, it sounds quite unbelievable but its quite magical how it does work actually. Amazing Linus Torwald.
TLDR: (its just a simple conventional hack by people to make a empty folder be indexable)
Docs: .gitignore @ SCM
Stackoverflow Answer: Click here
*to a nested folder’s
.gitignoreignore all files including the
.gitignorefile as well
.gitignorefile ignore all entities
The solution is recommended when you can manage to put all the commits after the nodemodules added to the repository to be squashed to a single commit because its a very _naive solution of my own to remove
node_modules from the git history.
node_modules from the most recent commit only via
# You can literally copy paste below commands to fix the shit. git rm --cached -r . # Reset the tracking area. echo node_modules >> .gitignore git add . && git commit --amend --no-edit # Amend last commit as it is(but with node_modules ``git ignored``)!
Another way if are in situation where lots of commits are made since you added
node_modules to the repository (i.e., BLUNDER HELL ehh..) via:
git branch temp # Make a backup branch of current branch's status. git reset --hard HEAD # Get to the desired/last commit where you didn't have node_modules. git merge --no-ff temp # Merge without making a commit. git rm --cached -r . # Now remove everything(_node_modules_) coz ```git merge --no-ff``` re-added everything to the the staging area. echo node_modules >> .gitignore git add . && git commit -m 'My new commit without node_modules.'