Lesson 2: Git and advanced Pelican features¶
Why do developers use Git?¶
A brief introduction to Git for beginners | GitHub Git is the most well-known version control system (though not the only one). Imagine having access to a file's entire history instead of just an "undo" command. You could check:
- who made a specific change
- what the file looked like
noperations ago- why the file was changed
Developers use Git to:
- track the history of changes in files
- access older versions of files
- collaborate with others on the same file simultaneously
- save multiple variants of the same project
Introduction¶
Opening our my-portfolio repository.¶
Creating a new branch and making changes on it¶
Creating a .gitignore file¶
The .gitignore file is used to specify files and folders that we do not want to share with others—such as cache files, secrets, or local settings. Changes to these files will not be tracked by git.
.gitignore
Here, we create a commit just as before. ### Merging changes into the main branch
Switch to the main branch:
Merge changes from the initial-python-script branch:
Check the commit history:
After a successful merge, the working branch is no longer needed, so we can delete it:
Reverting a change we don't want in the repo¶
git revert does not delete history. It creates a new commit that reverses the changes from a specific commit.
First, check the commit ID:
Then, revert the selected commit:
Example: