Module 7.5- Code Maintenance- Version Control Systems & Branching Flashcards

(16 cards)

1
Q

Understanding what Version Control Systems (VCS)

A
  • imagine working on a project where you can track every change you make, revert to a previous version, or collaborate with others seamlessly without worrying about overwriting each other’s work
  • that’s exactly what a version control system does-it helps you manage and keep track of your project’s history
  • Track Changes Over Time- every modification to your code is recorded, so you can see what changed, when, and by whom
  • Revert to Previous Versions- if something goes wrong, you can easily roll back to an earlier state of the project
  • Collaborate Efficiently- multiple developers can work on the same project at the same time without interfering with each other’s progress
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Types of VCS

A
  • Local VCS- a local VCS is one that stores the entire version history of a project on your own computer
  • this method is simple but lacks the collaboration features found in more modern systems
  • Centralised VCS- in a centralised VCS, like Subversion (SVN), there is a single central repository where all the code is stored
  • users check out the code, make changes, and then commit those changes back to the central repository
  • while it supports collaboration, it can be a single point of failure-if the server goes down, no one can work on the project
  • Distributed VCS- in a distributed system, every developer has a complete copy of the project’s history
  • changes can be made and committed locally, and then shared with others through a remote repository, such as GitHub or GitLab
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Benefits of a Distributed VCS

A
  • Greater Flexibility- can work offline and sync your changes when ready
  • Collaboration Made Easy-developers can work on their own copies of the code and merge changes back into the shared repository when they’re ready
  • e.g. if you’re using Git, you’ll have a complete local copy of the project and can work on it even without an internet connection- once you’re done, you can push your changes to a shared repository for others to access
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Using Git for VC

A
  • with Git, you can track every change in your project and collaborate with others smoothly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Git work?

A
  • operates by creating snapshots of your project, called commits
  • each commit represents a specific point in the history of your project
  • these commits can be shared with other developers through a remote repository, such as GitHub
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The Basic Git Workflow

A
  • Initialise the Repository- start by creating a new Git repository with git init
  • Stage Changes- as you make changes to your project, you use git add to stage the files you want to include in your next commit
  • Commit Your Changes- after staging, use git commit to create a snapshot of the current project state
  • add a meaningful commit message, like git commit -m “Fix login bug”
  • Push to a Remote Repository- when you’re ready, push your changes to a remote repository like GitHub with git push
  • Pull Changes from Others- if your teammates have made updates, you can use git pull to incorporate their changes into your local repository
  • e.g. after fixing a bug, you can create a commit like “Fix issue with user authentication” and push it to GitHub, where others can pull your changes and test them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Branching in Git

A
  • branching lets you work on a separate version of your project without affecting the main codebase
  • branches are essential when you want to experiment with new features, fix bugs, or collaborate without breaking the main project- they allow you to:
  • Isolate Work
  • Collaborate on Different Features
  • Keep the Main Codebase Stable
  • Create a Branch
  • Work on your Branch
  • Merge your Changes
  • e.g. if you’re adding a new login feature to a website, you could create a feature-login branch, work on it without affecting the live site, and merge the branch once the login system is fully functional
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Isolate Work

A
  • keep your experimental changes in a separate branch and merge them into the main project only when they’re ready
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Collaborate on Different Features

A
  • multiple developers can work on separate branches, avoiding conflicts and ensuring the main project stays stable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Keep the Main Codebase Stable

A
  • by working on feature branches, the main branch (often called main or master) remains free from bugs or unfinished features
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Create a Branch

A
  • let’s say you’re working on a new feature; you can create a new branch with git checkout -b feature-login
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Work on your Branch

A
  • make changes, commit them, and test your feature in this isolated branch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Merge your Changes

A
  • once you’re happy with your work, you can merge your feature branch back into the main branch using git merge feature-login
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Handling Merges & Conflicts

A
  • merging is when you integrate changes from one branch into another-often from a feature branch back into the main branch
  • while Git usually handles merging automatically, sometimes changes in different branches conflict with each other- this results in a merge conflict
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to handle Merge Conflicts?

A
  • Git will highlight the conflicting sections in your files
  • you’ll need to manually review and decide which changes to keep
  • after resolving the conflict, you can continue with the merge and commit the resolved code
  • if two developers modify the same line of code in different ways, Git will flag this as a conflict, and you’ll need to decide which version to keep or how to combine the two changes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Best Practices for Code Maintenance

A
  • Commit Frequently- regular, small commits make it easier to track your progress and pinpoint bugs if they arise
  • Write Meaningful Commit Messages- a clear commit message helps others (and future you understand what changes were made and why
  • Use Branches for Features- keep your main branch clean by developing new features in their own branches
  • Pull Changes Regularly- if you’re working in a team, frequently pull changes from the remote repository to ensure you’re always working with the latest version of the project
  • Test Before Merging- always test your changes before merging them into the main branch to avoid introducing bugs