This repository is my personal space for practicing Git and GitHub.
##Definitions -Git = is a software that should be installed in your computer so that you may have a local repository.
GitHub = is a website/service(online) that allows you to create a remote repository
GitLab-Another cloud service that hosts Git repositories
....................
NB: Repository is a storage location for digital assets like code, data, or files (It can be local(on your computer in git) or Remote(online in GitHub)).
##** When you work on your local repository(Git) you will need to send/sync with remote repository(GitHub) so others may be able to see your work and contriute if they wish to. or ##**when you want to contribute to other people's work you will need to Fork(get their work) from their remote repository(GitHub),clone their repository locally so that you may work on their work from your local repository(Git)
**You may do the following if its your first time setting git on your computer.
-
-git config --global user.name "your name" -git config --global user.email "your email" (only once as it means “Use this name and email for ALL Git projects on this computer.” ) .........................................................................
CREATING YOUR OWN REPOSITORY (2 WAYS)
1.Start LOCALLY, then connect to GitHub (a bit Advanced) =[Create a folder on your computer,(inside CMD cd to it(folder), and type:)git init,Create files e.g README.md, add it to git,Commit, Create repo on GitHub(same name as local repo), Link with git remote add origin(push)]
######[If you dont have GitHub repository yet but you want to start your work locally and setup the remote later, you may need to Initialise(git init) the folder you are working,
After 'git init',you will need to create a README.md file and write your first work,add it to git,and commit the changes (git add README.md git commit -m "Initial local commit"), go to GitHub and create the remote repo(With the same name as local)]
- Create repo on GitHub FIRST(Easier and Recommended) =[Create repo on GitHub,Clone it,Work,Commit,Push]
**[[There might be two ways of working on git: -sometimes you might clone your own repository (your work folder that you created) if you want to edit it or keep working on it (download it into your computer).
or
- If you want to contribute to someone's work, you first need to Fork their Repository,Clone it..and contintue with the same process as above.]]**
-
** Create a new repository (click '+' sign),Fill the Title and Description, Make sure Visibility = Public, and ADD a README.md.
-
Cloning a repository
- copy the repo link(GitHub),found under 'Code'(greenButton)
- In your CMD type cd Folder(where you want it saved) -& type git clone https//github...(the link you coppied) when done:
- cd to the cloned folder (usually the same title of your repo).
- open VS Code by typing "code .", you will be able to see the files in that folder (usually README.md).
- now edit it as you wish and save it(If its the one that you need to edit as per the instruction).
- In cmd type: git add README.md,git commit -m "commit message", git push/git push origin main(if working on main branch)/ branch name(if working on a separate branch)
-
git clone <repo-url>copies a remote repo locally.- Always check which folder you are in (
cd folder) before cloning.
-
Branching [[If you dont want to work on the original branch/main, create a new branch after cloning]]
git checkout -b branch-namecreates and switches to a new branch.- Branches are separate timelines for safe changes.
-
The core Git loop [[this is dne after you have edited/contributed]]
- Edit → Add → Commit → Push
git add .stages changesgit commit -m "message"saves a snapshotgit pushsends changes to GitHub
-
Pull Requests (PR) [After pushing to Github]
- A PR is a request to merge one branch into another.
- Useful for collaboration and review.
-
Lesson learned
- Always check your current directory (
pwd/cd) - Use branches to experiment safely
- PRs are the bridge between branches and main
- Always check your current directory (
- Practice multiple branches
- Practice PRs
- Start teaching others using these notes