[{"data":1,"prerenderedAt":478},["ShallowReactive",2],{"en-git-category-articles":3},[4,305],{"id":5,"title":6,"articleCover":7,"articleCoverEmbed":8,"articleCoverEmbedUploadDate":8,"articleCoverHeight":9,"articleCoverWidth":10,"authorId":11,"body":12,"categoriesIds":290,"description":292,"enAlternateSlug":293,"extension":294,"meta":295,"navigation":296,"path":297,"ptBrAlternateSlug":298,"publishedAt":299,"seo":300,"sitemap":301,"stem":302,"updatedAt":299,"wordCount":303,"__hash__":304},"blogEn\u002Fen\u002Fblog\u002Fhow-to-create-and-set-up-ssh-key-github.md","SSH Key in Git: How to Set Up an SSH Key for GitHub","\u002Fimages\u002Fen\u002Fblog\u002Fgit\u002Fhow-to-create-and-set-up-ssh-key-github-thumb.webp",null,720,1280,"thiago-nunes-batista",{"type":13,"value":14,"toc":283},"minimark",[15,19,22,27,35,73,76,86,93,103,131,135,142,155,169,172,184,195,199,202,245,256,259,263,279],[16,17,18],"p",{},"Git is the most popular tool for version control, and GitHub is the most widely used platform for storing your code in the cloud. However, having to enter your username and password every time you interact with GitHub can be quite inconvenient.",[16,20,21],{},"This is where the SSH key comes in. The key is used to establish a secure connection between your machine and GitHub, eliminating the need to repeatedly enter your credentials. In this article, I will guide you step by step on setting up an SSH key in GitHub to optimize your workflow.",[23,24,26],"h2",{"id":25},"generating-the-ssh-key","Generating the SSH Key",[16,28,29,30,34],{},"The first step is to generate the SSH key. You can do this by running the command below to generate the SSH key. Don't forget to replace ",[31,32,33],"code",{},"codigoaoponto@email.com"," with your email registered on GitHub:",[36,37,42],"pre",{"className":38,"code":39,"language":40,"meta":41,"style":41},"language-bash shiki shiki-themes dracula","ssh-keygen -t ed25519 -C \"codigoaoponto@email.com\"\n","bash","",[31,43,44],{"__ignoreMap":41},[45,46,49,53,57,61,64,68,70],"span",{"class":47,"line":48},"line",1,[45,50,52],{"class":51},"sAOxA","ssh-keygen",[45,54,56],{"class":55},"sIQBb"," -t",[45,58,60],{"class":59},"s-mGx"," ed25519",[45,62,63],{"class":55}," -C",[45,65,67],{"class":66},"seVfx"," \"",[45,69,33],{"class":59},[45,71,72],{"class":66},"\"\n",[16,74,75],{},"During this process, you will be asked about:",[77,78,79,83],"ul",{},[80,81,82],"li",{},"Adding a password to the SSH key.",[80,84,85],{},"Changing the directory where the SSH key will be saved.",[16,87,88,89,92],{},"In this tutorial, we will not worry about these options. For both questions, you can simply press ",[31,90,91],{},"Enter",". After these two questions, the SSH key will be generated.",[16,94,95,96,99,100,102],{},"If, for some reason, you want to generate the key in ",[31,97,98],{},"rsa"," format, the command will be slightly different, but the process will be identical, also requiring just pressing ",[31,101,91],{}," for the questions:",[36,104,106],{"className":38,"code":105,"language":40,"meta":41,"style":41},"ssh-keygen -t rsa -b 4096 -C \"codigoaoponto@email.com\"\n",[31,107,108],{"__ignoreMap":41},[45,109,110,112,114,117,120,123,125,127,129],{"class":47,"line":48},[45,111,52],{"class":51},[45,113,56],{"class":55},[45,115,116],{"class":59}," rsa",[45,118,119],{"class":55}," -b",[45,121,122],{"class":55}," 4096",[45,124,63],{"class":55},[45,126,67],{"class":66},[45,128,33],{"class":59},[45,130,72],{"class":66},[23,132,134],{"id":133},"obtaining-the-generated-ssh-key","Obtaining the Generated SSH Key",[16,136,137,138,141],{},"The second step is to copy the generated SSH key, and you can do this by running the command below, where ",[31,139,140],{},"key_directory"," should be replaced with the path to the public SSH key file:",[36,143,145],{"className":38,"code":144,"language":40,"meta":41,"style":41},"cat key_directory\n",[31,146,147],{"__ignoreMap":41},[45,148,149,152],{"class":47,"line":48},[45,150,151],{"class":51},"cat",[45,153,154],{"class":59}," key_directory\n",[16,156,157,158,161,162,165,166,168],{},"If you followed all the previous tutorial steps, the SSH key was generated in the default directory: ",[31,159,160],{},"~\u002F.ssh\u002Fid_ed25519.pub"," (or ",[31,163,164],{},"~\u002F.ssh\u002Fid_rsa.pub"," if you generated the key in RSA format). If you chose to save the SSH key in another directory, simply place the path to that directory after the ",[31,167,151],{}," command.",[16,170,171],{},"To display in the terminal the public SSH key saved in the default directory, use:",[36,173,175],{"className":38,"code":174,"language":40,"meta":41,"style":41},"cat ~\u002F.ssh\u002F.id_rsa.pub\n",[31,176,177],{"__ignoreMap":41},[45,178,179,181],{"class":47,"line":48},[45,180,151],{"class":51},[45,182,183],{"class":59}," ~\u002F.ssh\u002F.id_rsa.pub\n",[16,185,186,187,189,190,194],{},"The ",[31,188,151],{}," command prints the contents of a file in the terminal. In this case, it will display the ",[191,192,193],"strong",{},"public SSH key",", which you must copy.",[23,196,198],{"id":197},"adding-the-ssh-key-to-your-github-account","Adding the SSH Key to Your GitHub Account",[16,200,201],{},"Now that your SSH key is copied, the next step is to link it to your GitHub account:",[203,204,205,212,218,225,232,238],"ol",{},[80,206,207,208,211],{},"While logged into GitHub, in the upper right corner, click on your profile picture and select ",[191,209,210],{},"Settings",".",[80,213,214,215,211],{},"In the left menu, click ",[191,216,217],{},"SSH and GPG keys",[80,219,220,221,224],{},"Click the ",[191,222,223],{},"New SSH key"," button.",[80,226,227,228,231],{},"In the ",[191,229,230],{},"Title"," field, enter a description for the key, such as \"Personal Computer\" or \"Work Computer\".",[80,233,227,234,237],{},[191,235,236],{},"Key"," field, paste the contents of your public key that you copied earlier.",[80,239,240,241,244],{},"Click ",[191,242,243],{},"Add SSH key"," to save.",[16,246,247,248,251,252,255],{},"Once this is done, when you run a Git command such as ",[31,249,250],{},"git pull"," or ",[31,253,254],{},"git push",", GitHub will use the SSH key you generated and configured.",[16,257,258],{},"::img{src=\"images\u002Fblog\u002Fgit\u002Fadd-new-ssh-key-on-github.webp\" alt=\"GitHub page for adding SSH key\" width=\"658\" height=\"488\"}::",[23,260,262],{"id":261},"conclusion","Conclusion",[16,264,265,266,273,274,211],{},"This article guided you through generating the SSH key and configuring it in GitHub. If you want more complementary content on the subject, you can watch ",[267,268,272],"a",{"href":269,"rel":270},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=oNSIShMKP1s",[271],"nofollow","this video on the Código ao Ponto YouTube channel"," or access the ",[267,275,278],{"href":276,"rel":277},"https:\u002F\u002Fdocs.github.com\u002Fen\u002Fauthentication\u002Fconnecting-to-github-with-ssh\u002Fgenerating-a-new-ssh-key-and-adding-it-to-the-ssh-agent",[271],"official GitHub documentation",[280,281,282],"style",{},"html pre.shiki code .sAOxA, html code.shiki .sAOxA{--shiki-default:#50FA7B}html pre.shiki code .sIQBb, html code.shiki .sIQBb{--shiki-default:#BD93F9}html pre.shiki code .s-mGx, html code.shiki .s-mGx{--shiki-default:#F1FA8C}html pre.shiki code .seVfx, html code.shiki .seVfx{--shiki-default:#E9F284}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":41,"searchDepth":284,"depth":284,"links":285},2,[286,287,288,289],{"id":25,"depth":284,"text":26},{"id":133,"depth":284,"text":134},{"id":197,"depth":284,"text":198},{"id":261,"depth":284,"text":262},[291],"git","Learn how to generate, configure, and add an SSH key to GitHub for secure authentication, eliminating the need to enter your password for each access.","how-to-create-and-set-up-ssh-key-github","md",{},true,"\u002Fen\u002Fblog\u002Fhow-to-create-and-set-up-ssh-key-github","como-configurar-chave-ssh-no-git-para-usar-no-github","2025-02-04",{"title":6,"description":292},{"loc":297,"lastmod":299},"en\u002Fblog\u002Fhow-to-create-and-set-up-ssh-key-github",560,"mjyCucLlkFvpK7SCC_R6DVp3-1RBJlwkOR2PKdAVkpI",{"id":306,"title":307,"articleCover":308,"articleCoverEmbed":8,"articleCoverEmbedUploadDate":8,"articleCoverHeight":9,"articleCoverWidth":10,"authorId":11,"body":309,"categoriesIds":464,"description":466,"enAlternateSlug":467,"extension":294,"meta":468,"navigation":296,"path":469,"ptBrAlternateSlug":470,"publishedAt":471,"seo":472,"sitemap":473,"stem":475,"updatedAt":474,"wordCount":476,"__hash__":477},"blogEn\u002Fen\u002Fblog\u002Frecovering-lost-files-in-git-with-vscode.md","Recover Lost Files in Git Without a Commit Using VS Code Local History","\u002Fimages\u002Fen\u002Fblog\u002Fvscode\u002Fhow-to-recover-lost-files-in-git-using-vscode.webp",{"type":13,"value":310,"toc":458},[311,328,331,337,346,358,362,367,370,395,398,402,405,426,430,433,447,449,455],[16,312,313,314,317,318,317,321,324,325,211],{},"Git is the most widely used version control system in the market. As developers, we usually only scratch the surface of what this tool is capable of. In our daily routine, we tend to rely on basic commands such as ",[31,315,316],{},"pull",", ",[31,319,320],{},"commit",[31,322,323],{},"merge",", and ",[31,326,327],{},"push",[16,329,330],{},"However, Git is a powerful and complex tool. Incorrect usage can lead to serious problems, such as losing code that has not yet been committed to the repository. If this has ever happened to you, you probably felt that moment of panic, thinking all the time invested in that code was completely wasted.",[16,332,333,334,211],{},"If you use VS Code — one of the most popular code editors among developers — I have good news: ",[191,335,336],{},"in most cases, your code is not actually lost",[16,338,339,340,345],{},"In this article, I'll show you how to use a native ",[267,341,344],{"href":342,"rel":343},"https:\u002F\u002Fcode.visualstudio.com",[271],"Visual Studio Code"," feature to recover lost files, even if you never made a Git commit.",[16,347,348,349,352,353,211],{},"The feature we'll use is called ",[191,350,351],{},"Local History",", and it was officially introduced in VS Code version ",[267,354,357],{"href":355,"rel":356},"https:\u002F\u002Fcode.visualstudio.com\u002Fupdates\u002Fv1_66#_local-history",[271],"1.66, released in March 2022",[23,359,361],{"id":360},"the-solution","The Solution",[16,363,364,366],{},[191,365,351],{}," keeps a local history of changes made to files edited in VS Code, allowing you to go back in time and restore previous versions of your code.",[16,368,369],{},"To recover a lost file, follow the steps below:",[203,371,372,380,386,389,392],{},[80,373,374,375],{},"Press ",[376,377,379],"prose-kbd",{"value":378},"F1"," to open the VS Code command palette",[80,381,382,383],{},"Search for ",[191,384,385],{},"“Local History: Find Entry to Restore”",[80,387,388],{},"After selecting the command, look for the name of the file you lost",[80,390,391],{},"VS Code will display all saved versions of that file, along with timestamps of each change",[80,393,394],{},"Select the desired version and click to restore the code",[16,396,397],{},"That's it. Your file will be restored exactly as it was at that point in time.",[23,399,401],{"id":400},"important-notes-about-local-history","Important Notes About Local History",[16,403,404],{},"Before relying too much on this feature, it's important to understand its limitations:",[77,406,407,413,420,423],{},[80,408,409,412],{},[191,410,411],{},"Local History is stored only locally",", meaning it will be lost if you format your machine or clear VS Code data",[80,414,415,416,419],{},"It ",[191,417,418],{},"does not replace Git"," and should not be used as a version control strategy",[80,421,422],{},"The history has time and storage limits, so very old versions may be automatically removed",[80,424,425],{},"It only works for files that were opened and edited inside VS Code",[23,427,429],{"id":428},"best-practices-to-avoid-losing-code","Best Practices to Avoid Losing Code",[16,431,432],{},"Even with this feature available, preventing these situations in the first place is always the best approach. Some good practices include:",[77,434,435,438,441,444],{},[80,436,437],{},"Make small, frequent commits",[80,439,440],{},"Use branches for experiments and tests",[80,442,443],{},"Avoid working for long periods without committing changes",[80,445,446],{},"Always review what will be discarded before running destructive Git commands",[23,448,262],{"id":261},[16,450,451,452,454],{},"VS Code is an extremely powerful code editor. It offers so many features and shortcuts that it's nearly impossible to know everything it can do. ",[191,453,351],{}," is one of those lesser-known features that can make a huge difference.",[16,456,457],{},"If this article helped you recover lost code, consider sharing it with other developers. It might save someone's project — and sanity 😄",{"title":41,"searchDepth":284,"depth":284,"links":459},[460,461,462,463],{"id":360,"depth":284,"text":361},{"id":400,"depth":284,"text":401},{"id":428,"depth":284,"text":429},{"id":261,"depth":284,"text":262},[291,465],"vscode","Learn how to recover lost code changes using a VS Code feature called Local History, which saves different versions of your files, even without a Git commit.","recovering-lost-files-in-git-with-vscode",{},"\u002Fen\u002Fblog\u002Frecovering-lost-files-in-git-with-vscode","como-recuperar-arquivos-perdidos-no-git-pelo-vscode","2025-01-21",{"title":307,"description":466},{"loc":469,"lastmod":474},"2026-10-06","en\u002Fblog\u002Frecovering-lost-files-in-git-with-vscode",507,"p6ZQ_Hm34IgVoH1uuz9q1wK1f7HMyR19N6Wcjhc6Qmc",1791682337318]