INSTALL GIT .... but What is GIT?
GIT IS AN OPEN SOURCE AND FREE Source Control Management App THAT ENABLES TO TRACK FILES CONTENT HISTORY…. among other things
You can save and revert to multiple versions of a website, an app, or any other folder content
1 > Go to GIT website and download appfor your OS.
Installer Git sous Windows
Si vous ne l’avez pas déjà fait, téléchargez et installez Git pour Windows depuis le site officiel :
Git est un outil essentiel pour le développement web, et il est crucial de l’installer et de le configurer correctement pour chaque projet.
Étape 1 : Installer Git sous Windows
Si vous ne l’avez pas déjà fait, téléchargez et installez Git pour Windows depuis le site officiel :
Lors de l’installation, assurez-vous de sélectionner l’option pour inclure Git dans le “PATH” de Windows. Cela vous permettra d’utiliser la commande git depuis n’importe quel terminal, y compris l’invite de commande (CMD) ou PowerShell, et dans les dossiers de vos sites.
Étape 2 : Initialiser un dépôt Git pour chaque site
Une fois Git installé, vous devez initialiser un dépôt Git dans le répertoire de chaque site.
-
Ouvrez votre terminal (CMD ou PowerShell).
-
Accédez au répertoire de votre premier site :
cd C:\wamp64\www\drupal_new -
Initialisez le dépôt Git :
git initCette commande crée un sous-dossier caché
.gitqui contient toutes les informations nécessaires au suivi des versions. -
Répétez les étapes 2 et 3 pour votre second site :
cd C:\wamp64\www\drupal10_plk_newgit init
Étape 3 : Créer le premier commit
Maintenant que le dépôt est initialisé, vous pouvez effectuer votre premier “commit” (votre premier instantané du projet) pour commencer le suivi des modifications.
-
Dans le répertoire de votre premier site (
C:\wamp64\www\drupal_new), ajoutez tous les fichiers au suivi :git add . -
Enregistrez votre premier commit avec un message descriptif :
git commit -m "Initial commit"
Répétez ces deux commandes pour votre second site. Votre projet est maintenant sous gestion de version, et vous pouvez commencer à suivre les modifications apportées à vos fichiers.
This App works with Git Bash but once Git is installed on your OS, you can use many others such as PoweShell or cmd prompt,
SHELL CONFIGURATIONS
From Git Bash at FIRST USE:
– Specify your name:
git config –global user,name “Prenom Nom”
– Specify your email adress
git config –global user,email”monmail@maboite.com”
– Specify git branch
git config –global init.default branch main // branche initiale nommée main
Nest uou are done and can send git commands.
You can clear the Git Bash screen wiyh the command: clear
TRACK FILES IN A COMPUTER FOLDER WITH GIT
1- From Git Bash, navigate to the folder containing your files:
e.g. cd C:/Users/Rodol/Documents/Max\ 7/Max_on_Github
2 – Initialise your folder and content for Git management. This will create a hidden .git folder in your specified folder (in my case Max_On_Github: git init
=> CONGRATS! YOUR FIRST GIT FOLDER IS NOW SETUP
ANd Now?
– check the status for this repository: git status
=> Should reply with “On branch main ” and “No commits yet” if you just installed and congifured Git.
=> the git status shows also in my case “1 untracked file” in red and “nothing added” as my folder contains 1 file.So git does not care about these files yet.
To “ADD” or track a new file do: git add filename
in my case if i Add my only file mentionned above and do git status again, I will have a new line saying “Change to be commited” with the filename in green, and no more untracked files in Red.
To “Remove” or untrack a new file do: git rm –cached filename
To track all files except ignored files in a .git Folder: git add .
Now your files are on staging are ready to COMMIT your tracked files
COMMIT is like creating a snapshot of your tracked files in time order, so that you can travel to your files version history
COMMIT PRINCIPE to commit all a Folder content from the Folder location in GIt Bash:
git commit -m “Comment about this commit”
e.g. git commit -m “First commit – committing all files to the repository”
You can check other options now, among which the git log command described from git –help that will list you commits and comments by dates,
GET GIT HELP
cUse the commands
git config -h // to open help
git help + Command: e.g. githelp config // to open config commands infos manual
How to Make Git Ignore some files in a .git repository
.
1) You need to create a specific hidden file name .gitignore from a text editor.
2) You need to set commands in the files depending on the files to hide
For instance, to remove any file .txt (with a comment line for better practice ) do:
#ignore all .txt files
*.txt
GitHub and Gitlab and first repository push from local to github
Github is sort of a social media platfrom where you can store and share you repositories, i.e. you git floders.
Gitlab is an open source equivalent, but as GitHub is more populaar in the professionnal world, I will focuse here on detailing the basics for using GitHub.
Source: https://www.youtube.com/watch?v=tRZGeaHPoaw @32’36
Why doing this?
– To work in collaboration with other people and associated tools by sharing private project repositores
– TO have a BACKUP of your local folder
So far you used a local repository (i.e. a git enables folder in your computer)
But you can do the same for free in a cloud on github or gitlab.
1) GO th github.com and create an account.
2) Connect to your new account and you can create your first repo:
– enter a name for the repo- opt. enter a description
– setup private / public settings
– check other optionnal options
=> Clic on create repository
=> Once done, the next page will show a quick setup guide explaining how to push your local repository to github, or do other on create manipulations.
3) Import your local files
= from the quick setup guide showing up after the github repo creation, copy/paste the following commands in your bash or cmd terninal (windows):
a) connect to distant github: git remote add origin http//your_github_repo_page_name
b) specify branch to send: git branch -M main
c) push the local content to github: git push -u origin main
4) You’re done. Check result by clicking to your github repo content
Example:
git remote add origin https://github.com/RodolpheKoehly/PLK-MINI-MAPS-2024.git git branch -M main git push -u origin main