Newbie's guide to Anvil and Git/Github

Hi all,

I’m new to Anvil and sometimes feel I don’t properly understand/use Git/Github and have suggested elsewhere that it might be helpful to have a more basic, step-by-step Tutorial for getting set up for version control, collaboration, and management of DEV, TEST and PROD environments. I have searched the Forum quite thoroughly (I think) and the previous threads I’ve found or other people have pointed me to have either not answered my particular problem or are simply not beginner-friendly enough to help me succeed.

So in the meantime, here’s my setup and the problem I’m experiencing… If anyone can help tell me what I’m doing wrong or what else I need to do, or actually suggest the steps an Anvil/Git newbie needs to follow, I’d VERY grateful. Thank you!

MY SETUP

  1. I have a free Anvil account peter@... and a business one wgaca@...
  2. I have a GitHub account peter@... and while troubleshooting this problem also created a wgaca@... Github account.
  3. I have Github Desktop for Windows which I use instead of the command line since I struggle with the Git ‘incantations’. By default it’s setup with peter@...
  4. My eyes glaze over whenever I see tutorials that assume Linux setup and knowledge (which I don’t have).
  5. I think I understand the basics of Git/Github and have successfully set up public and private repositories in the past, cloned them locally, created branches for DEV, TEST, and MASTER and am comfortable swapping between them.
  6. I also use VS Code for non-Anvil Python coding and am comfortable performing those Git/Github functions from within VS Code.
  7. I do not understand or use SSH certificates currently.
  8. I’ve successfully created different DEV, TEST, and PROD copies of my app within Anvil (wgaca@...) itself and now how to share by link, download as a single YAML file, and re-import as a YAML file.

WHAT I’VE TRIED SO FAR

  1. Using Anvil: App Menu, Share App, Clone with Git

  2. Copy the incantation into the Windows command prompt after navigating to the desired directory

  3. Enter my (Anvil wgaca@... ?) password when prompted.

  4. This successfully creates new folders and files which I can browse and edit manually with no problems.

  5. Using Github Desktop: File, Add Local Repository, I select the newly created folder, and Add repository:

  6. image

  7. I manually add a test file LICENSE.txt to the root folder and it correctly shows as a change in Github Desktop:

  8. I Commit to Master (successfully) then try Push to Origin, which is where it fails:

  9. Thinking that I might need to be logging on to Github using wgaca@... I go to File, Options, Signout then Sign In again with wgaca@... email and password. I also replace my email and display name in File, Options, Git for good measure.

  10. I restart Git Desktop just in case, and try Push to Origin again. But get the same error message :confounded:

2 Likes

questions:

  • in your flow have you set up remotes?

  • what is the origin remote repositry - is it anvil or github?

1 Like

I had a similar issue as @AWSOM, currently using a work-around and will test the “add remote branches” suggestion by @stucork, brief description of my setup;

using git cli commands from a GCloud Shell on a VM (same geolocation as Anvil, so timeouts not applicable). Commit to master etc. pushed no files to github. That VM does have extended TLS setup, instead of standard wildcard, which might have an effect?

I’ll retry from Windows cli on my local machine to better simulate @AWSOM’s environment and post results here.

1 Like

My work flow is as follows

  • add ssh keys to anvil and github as per this tutorial:
    (I don’t think it’s necessary but saves the hassle of passwords)

https://youtu.be/hQWRp-FdTpc

  • 3 remotes:
    • github, anvil_prod, anvil_dev (origin)
  • local machine

  1. clone from anvil_dev to local machine (anvil_dev is now origin)
  2. add remotes github and anvil_prod using the command: git remote add <name> <url>
  3. make edits in anvil ide in anvil_dev
  4. pull edits to local machine from origin (anvil_dev)
  5. push to github and anvil_prod
  6. if I have problems with pushing to anvil_prod it’s usually because i’ve inadvertently opened it and have a ‘saved automatically’ commit so I’ll force push the changes to anvil_prod
    (or i’ll go to the ide, version history, roll it back to the commit before ‘saved automatically’ and then push again)

For README.md and licences, I make these on my local machine and push these changes to all the repositories. They are viewable in github but not in the Anvil IDE.


i typically use vscode with the add ons: Git Graph and GitLens
Git Graph makes it easy to see the commit histories and
GitLens has some extra features compared to VS code’s builtin git tool (such as seeing your remotes easily)


2 Likes

Hi Stu - Sorry to show my ignorance but I I don’t understand either question, so I guess the answer to remotes is no, and the answer to origin is “I don’t even know how to find out. Sorry…”

Will reply to your other answer in a second…

Thanks for the YouTube link @stucork - For the benefit of others, the Github bit comes about 40 minutes in to the video i.e. https://youtu.be/hQWRp-FdTpc?t=2376, and my summary of the entire introduction is:

"SSH stands for Secure SHell and is a way of logging in to servers (or services such as Anvil/Github/Digital Ocean etc.) without using Passwords. You generate a public and private key which is saved to your HOME (or USER) directory by typing ssh-gen (or ssh-keygen -t rsa … not sure what the difference is or if it matters?) from the command line, and then copy/paste/save the public key to the server or service you want to access."

Step 0 (add ssh keys to anvil and github): Github apparently requires other specific parameters i.e. ssh-keygen -t rsa. Just to check, although the video explains how to have separate keys for different servers, can that same SSH key be used for Anvil AND Github or doesn Anvil need a different specific type of SSH key?
Step 1: Thanks for explaining what origin (and remotes) means with examples - new terminology for me so definitely needs to feature in any final ‘Tutorial’ we come up with.
Step 2: Sorry to be a pain but could you be more prescriptive about what to put in <name> and <url> please? Also I think a key concept I was missing (if I now understand you correctly) is that Anvil already automatically has/is a remote which you can push to and pull from but you need to set up SSH first? You said you think SSH isn’t necessary but I’ve been unable to get things working with just passwords so far… so I’m pinning my hopes on SSH for sorting this out!
Step 4: Is there anything else I need to do in Github Desktop to setup SSH before pulling?
Step 5: Is there anything else I need to do in Github Desktop to setup SSH before pushing?

I’m writing this without having retried up to Step 5 (which I’ll do later this evening and report back and if successful, summarise everything in a final step-by-step Tutorial).

1 Like

step 0 - you can use the same public ssh for all your ssh needs if you wish.

step 1 - origin just means original - so the original remote you cloned.

step 2 - <name> - whatever you choose like anvil_prod
          - <url> - the url of your remote
e.g.
the bit with ssh://
Screen Shot 2020-04-09 at 06.50.12
or
Screen Shot 2020-04-09 at 06.49.22

so above I would do:

$ git clone ssh://stucork%40gmail.com@anvil.works:2222/ABCDECF312WJFOK2.git Tabulator
# this is origin (anvil_dev)
$ git remote add anvil_prod ssh://stucork%40gmail.com@anvil.works:2222/TGQCF3WT6FVL2EZ2.git
# this is a separate anvil app for production
$ git remote add github https://github.com/s-cork/Tabulator.git
# github remote

Anvil already automatically has/is a remote

yes - your anvil apps are all remote git repositories with urls that you can use to access them.
When you push and pull from your anvil remote you’ll either need to have set up ssh or use your anvil email and password.

(Though i’ve never used it with emails and passwords so I can’t speak to any authentication issues.)


with an anvil git workflow rather than having branches in your anvil app - like you would typically do in github or on your local machine - you should think about each anvil app as it’s own branch. The reason being - (unless i’m mistaken) the branch you are working on in the IDE is always the master branch.

You can check this by doing

print(app.branch) 

when you run your anvil code


edit: for pushing - in vs code i typically do this… in order to specify which remote to push to

Screen Shot 2020-04-09 at 07.39.06

the incantation would be:

$ git push <remote-name>

if you don’t specify a remote name it will default to origin

2 Likes

Thanks all… I’m now up and running :grinning:
Please have a look here…

Hey all.

I am having some of the same issues as @AWSOM , but none of the provided solutions are covering my bases here. In my setup i had chosen to use Putty, pageant and had set my GIT_SSH environment variable to point at plink.exe. This prevented me from cloning my repos, most likely because I was using Plink, and did not have the slightest clue on what that actually means for my development process.

After removing the GIT_SSH environment variable for my installation of GIT, thereby removing the Plink dependency, and following the provided steps from level 6+7 in the (Unofficial) Anvil Version Control for Dummies I could finally clone the repo to the PC.

Thanks for the help and provided suggestions.
Best regards
Jesper

2 Likes

Thank you for the kind words and for confirming Level 6+7 actually work (not just for me!) @JayKayAce!

2 Likes