How to Backup and Share pyRevit Code

...

How to Backup and Share pyRevit Code

...

Summary

Why Back Up Your pyRevit Code

As pyRevit developers, you should all back up your code regularly. We all postpone it until one day we lose a chunk of data and then regret not doing it earlier.

I speak from personal experience, as I've also lost a bunch of scripts because I rushed and made some mistakes.

So let's back up your code before it's too late.

Backup Options

Firstly, Let's discuss your backup options.

  • Local Storage: You could take an SSD drive, connect it, and drop your files there once in a while, but this is not robust.


  • Cloud Sync Services: Many people like to sync folders to the cloud using services like Dropbox, GDrive, or OneDrive…

    They automatically sync their code to the cloud for safe backup and easy access from multiple devices. But this option is not recommended for sharing your extension with the team as it can produce some unexpected error messages.


  • Git: Instead of that, you should all back up your extensions on Git. This is the best option by far for any code.

    You can use platforms like GitHub to secure your code and be able to share it with your team.

What's Git?

Now, let's talk about what is Git.

Git is a tool that helps developers to keep track of changes made to files. It keeps version history and allows seamless collaboration on code projects between different developers.

I know it still sounds confusing, but let's have a look at a Git example.

Git Example

Have a look at this visual example of a Git branches.

Each dot represents a saving point on the git, and you can see that it can branch out from the main 'Master' branch (Green line)

Imagine a green line in the middle representing the main codebase of your repository. Each dot represents updates or saving files to your Git branch.

  • Starting Point: On the left, we start with the first dot, and in there, we have files 1, 2, 3, and 4, all with version 1.0.

  • Feature Development: You decide that you want to work on Feature One and you don't want to affect the main branch. So we're going to branch out to the Feature One branch, and you're going to modify files 1 and 3. You save two times.

  • Another Feature: Then, somewhere in the middle of working on Feature One, you also decide to work on Feature Two. So you make another branch and work on files 2 and 4.

  • Merging Back: Whenever your features are ready, you're ready to merge them back into the main codebase. You can see that Feature One went into the first green dot on the right, and Feature Two went to the second green dot.


The best part about Git is that it allows you to monitor all the changes that you make.

You can compare any states, and you can see all the code changes. If you ever need to go back in time and look at what the code state was and bring it back, it's all possible. This is the main benefit of using Git for backing up your code.

How Do You Use Git?

There are multiple option on how to use git.

When you want to use Git, GitHub is by far the most popular and free option.

There are a few otoher providers like BitBucket and a few others, but they can only compete on enterprise level in my opinion.

Install GitHub Desktop (Beginner-Friendly)

Now we've finished the main points about Git in this presentation, and it's time for practice. Let's setup the most beginner-friendly option.

  • Download GitHub Desktop

  • Install as usual

  • Create GitHub Account

  • Login in GitHub Desktop to your account


If you need help with any of these steps, refer to the video where I show you how to do that step by step.

Create New Repository

Now let's create a new repository. Think of it as a folder on the GitHub.

This is not a complicated step, just provide a few details and click on Create Repository.

Next Make sure you publish your repository so you can actually see it on the GitHub.

Now you can open your GitHub account and check your repository.

Add pyRevit Extension Files

Now you have a folder on your machine that is synced to the GitHub repository. Now you can put all your pyRevit files inside this folder.

Then you will need to:

  • Select Files to 'Commit"

  1. Provide name for the change

  2. Click on Commit to main branch (Accept the Change)

  3. Push to Repository (Send Data to GitHub)

GitHub Secret

Btw, there is a really cool secret about GitHub that no many people are aware of. You can open your Repository on the GitHub website and then you can change website domain from .com to .dev and it will open web version of VS Code IDE, which is much better way to explore GitHub.

You can even make changes and commit them.





P.S.

Summary is Work in progress

HomeWork

⌨️ Happy Coding!

Questions:

Q1

Q1

Discuss the lesson:

P.S. Sometimes this chat might experience connection issues.
Please be patient or join via Discord app so you can get the most out of this community and get access to even more chats.

P.S. Sometimes this chat might experience connection issues.
Please be patient or join via Discord app so you can get the most out of this community and get access to even more chats.

© 2023-2024 EF Learn Revit API

© 2023-2024 EF Learn Revit API

© 2023-2024 EF Learn Revit API