Projects/git how go back to older project state?

I was now able to configure projects/github thanks the help of @Colin:

/enable-projects-for-using-github-is-not-working

Now I have the question: how can I go back to an older state of my project with projects/git state in den Node-RED UI? For example I do something wrong and want go go back to my commits from yesterday.

Can anybody help my with that?

Hi @nosebaer

that is not something the Projects UI currently exposes. It's on the todo list.

For now, you can do it via the command line.

  1. open a terminal and go to ~/.node-red/projects/<name-of-project>
  2. run git log --format=oneline to get a list of recent commits:
[~/.node-red/projects/node-red-todo-app2 (test)]$ git log --format=oneline
93a8eb85de929d109cf4019f5ed4d5494fb9e30a (HEAD -> test, origin/test) test chanr
3f1e591427d8ef061dfccb635115f5ff0a7abdd7 (origin/master, origin/HEAD, master) Add top license file
38eeddd37d5c8f7d0cacd6ecb1858bca9e6c915a Create project
1a29ded7fb048d2f2e2e37907191b322915b925a Create project files
  1. From that output, identify the commit you want to go back to and copy the long hexidecimal string at the start of the line.

The next step will depend on whether you want to throw away all of the more recent changes, or if you want to add a commit that reverts the changes but keeps them in the history.

If you want to throw away the more recent changes, you can run:

git reset --hard <the-hexidecimal-commit-id>

If you want to keep the more recent changes in the history, but take the files back to the earlier state, then you can use:

git revert <the-hex-id>..master

It will create a new commit for each commit you are undoing.

In newer versions of git there is also git restore... but I haven't played with that yet.

Once you've done all of that, you'll need to restart Node-RED and reload the editor.

4 Likes

Also you could install gitk and that will show you all the commits in a GUI and allow you to revert them.
git gui is also excellent for seeing the changes made since last commit.

2 Likes

I just use VSCode (and GITLENS) as I have it installed for development...

image

1 Like

Hi @Steve-Mcl,

thank you very much for this. I will test these tools.

Thanks! I`ll figure out this tools.

Hi @knolleary,

thanks a lot for this detailed explanation! Good to know that there is an manually way.

How can I keep posted, when this will implemented in the Projects UI?

It's an item on the backlog. I don't know when it'll get prioritised, unless someone else comes along eager to help implement it.

If/when it gets implemented, it'll certainly get mentioned in the release notes.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.