Coder Social home page Coder Social logo

git-config's Introduction

Git-Tips-and-Tricks

Configure Git

git config --global user.name "your_username"
git config --global user.email "[email protected]"
git config --global --list

Don't write every time userName and Password

Write user & password first time and along with this write below code that specify when timerout expires


git config --global credential.helper "cache --timeout=86400"

How to delete a Git repository

Steps to delete a local Git repo

  1. Open the the local Git repo’s root folder
  2. Delete all of the files and folder in the Git repo’s root folder
  3. Delete the hidden .git folder with File Explorer or through the command line
  4. Run a git status command. A fatal: not a git repository error verifies that the Git repo is deleted

Command line Git repository delete

If you’re familiar with the terminal window or the DOS prompt, you can easily perform a command line Git repository delete. Just run the rm command with the -f and -r switch to recursively remove the .git folder and all of the files and folders it contains.

This Git repo remove command also allows you to delete the Git repo while allowing all of the other files and folder to remain untouched.

rm -fr .git

Divergent branch problem

You have divergent branches and need to specify how to reconcile them

1. git pull --ff-only
2. git pull origin master

Your code uploaded to github

Divergent branch problem

when Previous solution not working then Use This technique

  1. click Code copy HTTPS LINKS
  2. Run
   git clone <HTTPS LINK>
  1. Paste Your previous file Which not uploading to github
   git push origin master

Your code uploaded to github

How to visit(Traverse) previous commits

list of previous commits and show #code's

git log --oneline
git checkout <#code>

How to Revert to a Previous Commit Using the git reset command

git reset works with local repository

list of previous commits and show #code's

git log --oneline
undo the previous commit
git reset <#code> --hard

git revert works with online repository

git revert <#code>

How to Rename Branch

list of branch
git branch
Rename branch
git branch -m <oldBranchName> <newBranchName>

How to Rename Previous commit

git commit --amend -m "New commit message."

Fix issue

Solve any issue in Git You must run this command after every command to see What going on

git status

github CLI setup

 sudo apt install gh
gh auth login

Giving permission to github CLI delete the repo

 gh auth refresh -h github.com -s delete_repo

Create a repo at one click

gh repo new/create <repo name> --public
                               --private
                               --internal
                               

Delete a repo at one click

gh repo delete <repo name> --confirm

Rename a repo

gh repo rename <new-repo-name>

Most used github shortcuts

most used github shortcut


When something change remote but not present locally and wanted to push my code to remote then this proble occurs

First solution

git push origin master -f

Screenshot from 2023-05-19 22-49-22

Second Solution(recomended)

git pull origin master
git push origin master

git-config's People

Contributors

webdev-ashishk avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.