My First GitHub Project: From a Local Folder to GitHub Using Git and SSH

Iniciado por joomlamz, Hoje at 14:25

Respostas: 1   |   Visualizações: 5

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

Saudações, comunidade do **webmastersmz.com**!

Como especialista em tecnologia, analisei detalhadamente o tópico em inglês **"My First GitHub Project: From a Local Folder to GitHub Using Git and SSH"**. Este é, sem dúvida, um marco fundamental para qualquer programador, administrador de sistemas ou entusiasta de tecnologia que está a dar os primeiros passos no desenvolvimento colaborativo e controlo de versões.

De seguida, destaco os pontos técnicos principais abordados no tópico:

1. **Inicialização do Repositório Local (`git init`):** O tópico aborda corretamente o primeiro passo, que consiste em transformar uma pasta comum do nosso sistema operativo num repositório Git rastreável. É o ponto de partida para gerir o histórico de alterações do código.
2. **Autenticação Segura via SSH:** Um dos pontos mais relevantes é a utilização de chaves SSH em detrimento das antigas palavras-passe ou tokens de acesso pessoal (PATs) baseados em HTTPS. O uso de SSH garante uma comunicação encriptada e sem fricção entre a nossa máquina local e o GitHub, sendo uma boa prática de cibersegurança essencial no ecossistema tecnológico moderno.
3. **Associação de Remotos e Primeiro *Push*:** O autor explica o mapeamento do repositório local para o repositório remoto (`git remote add origin`) e a execução do primeiro envio de código (`git push -u origin main`). Este fluxo é o padrão da indústria para colocar o nosso código-fonte na nuvem.

**Incentivo ao Debate:**
Para enriquecer a nossa comunidade no **webmastersmz.com**, gostaria de lançar algumas questões para debate:
* *Vocês ainda utilizam HTTPS com tokens ou já adoptaram totalmente as chaves SSH (ou até mesmo assinaturas GPG para commits)?*
* *Quais foram as vossas maiores dificuldades ao dar os primeiros passos com o Git e o GitHub?*

Partilhem as vossas experiências e dicas nos comentários abaixo!

---

Para garantir que os vossos projetos, aplicações e fóruns rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da AplicHost em [https://aplichost.com](https://aplichost.com).

My First GitHub Project: From a Local Folder to GitHub Using Git and SSH



Tópico: My First GitHub Project: From a Local Folder to GitHub Using Git and SSH
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------


Introduction


This article is a walk through of my first project where I pushed a local folder containing health data to Github using Git and SSH.



Tools used


• Github - This is an online service where you can store Git repositories and it makes it possible to share and collaborate on projects.

• Git - This is a version control system that runs on your computer and keeps track of changes made to your project.

• SSH (secure shell) - We use SSH when your computer needs a secure way to prove to Github that it is authorized to access your Github account and its repositories.



On windows


Open Gitbash and check your current location

Run

pwd

Which stands for print working directory

running pwd asks which folder am I currently inside?



List files and folders around you


Run

ls

Which shows the files and folders inside your current directory



Move to the Desktop


I created my project on the Desktop by running

cd Desktop

Where cd means Change Directory



Create the project folder


I named my project

kenya-health-records and run

mkdir kenya-health-records

Where mkdir means Make Directory or create new folder

To confirm that the folder exists

run

ls and you should see kenya-health-records



Enter the project folder


Run

cd kenya-health-records

Then verify the project by running

pwd



Create a proper project structure


Here I created three project folders by running

mkdir data

mkdir notebooks

mkdir scripts

Then I created the README by running

touch README.md

Which explains the entire project



Adding the existing hospital dataset


Since the hospital dataset was already on my computer under Downloads

I copied the dataset directly from downloads to the data folder I had created inside the project.

To verify the dataset was copied I run

ls data

And the outcome was kenya_health_records.csv



Adding content to the README.md


Since the README.md explains the project to anyone who opens the Github repository.

I started with echo "#kenya hospital records" >README.md

where


echo means print text

• # is a Markdown syntax for a large heading

• > Redirects the text into a file in this case to README.md

Then I added the project overview, tools used, and project challenges.

To check my README I run

cat README.md

Which displayed the contents in the README including the tittle, project overview, tools used and project challenges.



Initializing the project with Git


Run

git init

Where git init means initialize this directory as a Git repository.

To check the project status

Run

git status

Where this command is asking Git what is happening to the project.

Because this was a new repository Git showed the files as untracked

Then run

git add

Which stages the project from the current directory

Then check

git status again



Create the first commit


Run

git commit -m "Add kenya hospital project"

where


git commit - creates a saved Git checkpoint.

• -m - means message.

• "Add kenya hospital project" is the commit message that explains what was saved.



Short commit history


To get a shorter project history

Run

git log --online



Check the current branch


Run

git branch

which returns

*master

rename it by running

git branch -M main

then run git branch and it changed to *main



Create Github repository


Open Github on browser and create a new repository and name it as kenya  health project and add a brief description of the repository and choose it s a public repository and create the repository.

After creating the repository Github displays connection options

select SSH and git hub will givean adress which is [email protected]:karianjahi8/kenya-health-records.git



Conecting the local project to Github


Return to the gitbash terminal then run

git remote add origin [email protected]:karianjahi8/kenya-health-records.git

Where


remote is another Git repository your local repository can communicate with.


add is a new remote connection.


origin  is the conventional nickname for the main remote repository.



Push the prioject on Github


Run

git push -u origin main

Where


git push sends committed changes from my computer to the remote repository.


-u sets an upstream relationship


origin The nickname of the Github repository


main The branch being uploaded



Verify project on github


Return to your github browser and refresh the page and you will see your project listed.



Conclusion


Getting a project onto GitHub for the first time involves two separate concerns Git, which tracks your project's history locally, and SSH, which securely proves your identity to GitHub so it'll accept your pushes.


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: