Git Integration

Description

Change any Project to a Git Repository with a click of a button.

Discussion

Git and GitHub support is integrated into the Web Projects Control Panel. When the Web Projects Control Panel is displayed, you will see a Git icon on the far right-hand side of the toolbar in the Control Panel.

images/git9.png

You must install Git on your machine to use this feature. Git is a free install. You can find the installer at: git-scm.com/downloads. When you install Git be sure to select the option that adds Git to your path. See Installing Git below for detailed installation instructions.

Converting an Existing Project to a Git Repository

You can make an existing project into a Git repository by clicking the Git icon.

This will display the Git Menu dialog as shown in the image below.

You can make the current project into a Git Repository by clicking on the Yes - Make a Git Repository button, or you can clone an existing GitHub repository.

images/git1.png

If you convert a large Web project into a Git repository, (and you check the Add all files checkbox prompt shown in the image above) Git may take a significant amount of time to add all of the files to the Repository.

Adding and Committing Files

Once you have made your Web project into a Git repository the Web Control Panel will show a Git toolbar under the main toolbar shown in the Window.

Once you have made your Web project into a Git repository the Web Control Panel will show a Git toolbar under the main toolbar shown in the Window.

The Git toolbar shows you the number of Untracked and Modified files in your project.

images/git2.png

Untracked files are files that are not included in the Git repository. This includes new files or files that have been renamed.

Modified files are files that are included in the Git repository. Modified files include files that have been changed or missing. A file can become missing if it has been deleted or renamed.

To commit any modified files, or to add untracked files to your repository, click the Git button on the toolbar, or click directly on the Untracked files or Modified files message on the Git toolbar.

images/git3.png

When you click the Git button you will see the Git Commit window where you can select which files you want to commit and which currently untracked files you wish to start tracking. You must enter a commit message before you can click the Commit button.

Once you have committed files, the modified files and untracked files count in the Git toolbar will update.

images/git4.png

Connecting your Git Repository to GitHub

You can connect your local Git repository to a remote GitHub repository. Once you have done this you will be able to push and pull to and from the GitHub repository using the Push to GitHub and Pull from GitHub hyperlinks on the Git toolbar.

In order to connect your repository to a remote Git repository, click the Git Settings hyperlink in the Git toolbar.

First, select the Save User ID and password for GitHub to enter your credentials for your GitHub account. The password needs to be a personal access token. The personal access token, at a minimum, needs repo scope in order to perform push and pull actions against the GitHub repository.

Next, select the Register/change remote GitHub repository command. This will open a dialog (shown below) where you can enter the URL for your remote GitHub repository.

images/git5.png

You must have your own GitHub account to push and pull changes to a repository on GitHub. Visit GitHub to sign-up.

images/git6.png
Enter the URL for the GitHub repository in the text box.

Editing the .gitignore File

Your web project may have certain files that you do not wish to be part of your Git repository. The list of files and file types that you want to ignore is defined in the .gitignore file. You can edit the .gitignore file by selecting the Edit the .gitignore file from the Git Settings menu.

images/git7.png

Adding a New Project as a Git or GitHub Repository

When you create a new Web Project (by clicking the New Project button in the Web Control Panel), you can specify if the new project should be a Git repository.

You can also create a new project from a remote GitHub repository.

images/git8.png

Git Settings Menu

  • Edit the .gitignore file

    Opens the .gitignore file for editing. Use the "" link to insert the default recommended list of files to ignore. You can manually list files and folders to ignore here or use the Commit dialog to add them.

  • Register/change remote GitHub repository

    Used to change the remote GitHub repository URL for your Project. To disassociate your project with a GitHub repository, delete the URL in this dialog.

  • Save User ID and password for GitHub

    Used to set the User ID and classic personal access token associated with the GitHub repository for the Project. You must set the User Id and personal access token if you want to use the GitHub push and pull features in Alpha Anywhere. The personal access token must be a classic token and have, at a minimum, repo access.

  • Customize color coding

    The Customize color coding options allow you to change the colors used to indicate files are modified, tracked, untracked, and unmodified (committed). Color coding is used in the Web Projects Control Panel.

    Tracked files

    Color shown for files when you convert a project to a Git repository but have not committed the repository yet.

    Untracked Files

    Color shown for files that are not tracked in the Git repository (i.e. new files in your Project).

    Modified Files

    Files that are tracked in the Git repository and have modifications.

    Committed Files

    Files that are tracked in the Git repository and have no modifications.

  • Delete Git Repository

    The Delete Git Repository option will delete the Git repository and settings associated with the project. This includes deleting all file history. Use with caution.

    You can manually delete a Git repository by deleting the .git folder located in the Project directory.

  • Customize commands used to Push/Pull repositories

    You can customize the commands to push and pull repositories. This allows you to connect your repository to an server other than GitHub.

    To define custom push/pull command click the Git Settings hyperlink on the Web Control Panel.

    Then, define the commands to use to Push and Pull your repository.

    images/gitcustomize.jpg

Private Repositories

You can now create a new project from a private repository on GitHub. You will be prompted to enter your GitHub username (must not include '@' ) and your personal access token. Note that a classic personal access token is recommended.

Installing Git

  1. Before you can use Git with Alpha Anywhere, you must first Install Git. Go to git-scm.com.

  2. Click "Downloads".

  3. Select "Windows" to download the Git installer for Windows. Your download should begin automatically.

  4. When the download completes, run the Git installer.

  5. On the Select Components, keep the default settings.

    images/gitInstall1.png
  6. On Choosing the default editor used by Git, you can optionally select a different editor. The editor is used from the Command Line primarily when resolving merge conflicts and entering commit messages with Git. The default, Vim, is a difficult editor to use. If you plan to use Git outside of Alpha Anywhere, it's recommended that you install a text editor such as Notepad++ or Visual Studio Code.

    If you only plan to use Alpha Anywhere with Git, you can leave the default here as Alpha Anywhere will provide its own interface for working with Git. You can always change this setting later.

    images/gitInstall2.png
  7. On Adjusting your PATH environment select "Git from the command line and also from 3rd-party software". This will add Git to the PATH environment variable, which is required to use Git with Alpha Anywhere.

    images/gitInstall4.png

    If you plan to use Git in windows Command Prompt, you can optionally select instead "Use Git and optional Unix tools from the Command Prompt". This will add Unix tools to the PATH variable in addition to Git, allowing you to use Unix tools such as "find" and "sort" in Windows Command Prompt. Do not select the first option.

  8. On Choosing HTTPS transport backend, select "Use the native Windows Security Channel library".

    images/gitInstall5.png
  9. On Configuring the line ending conversions select "Checkout as-is, commit as-is".

    images/gitInstall6.png
  10. Use the default setting on Configuring the terminal emulator to use with Git Bash.

  11. On Configuring extra options uncheck all three options.

    images/gitInstall8.png
  12. Click Install. When installation completes, Git can now be used in Alpha Anywhere.

  13. Close and restart Alpha Anywhere if it was running while your were installing Git. You need to do this because the Git installation modified the PATH environment variables, which are cached when Alpha Anywhere launches.

How to Clone an Alpha Anywhere Sample Application from GitHub

  1. Go to https://github.com/alphaanywhere

  2. Click on "Repositories"

  3. Select a Repository that is labelled as "Works with Git in Alpha Anywhere".

    images/gitHub3.png
  4. Copy the repository URL from the Address bar

    images/gitHub1.png
  5. In your Alpha Anywhere workspace, create a new project on the Web Projects Control Panel (File > New Project).

  6. Select the Create Project from a GitHub Repository radio button.

  7. Enter a name for your new project.

  8. Paste the URL you copied in the URL box.

    images/gitHub2.png
  9. Click OK to create your project.

    Depending on your network connection and the size of the repository, it may take some time to clone the project locally.

Troubleshooting

  • Creating a new Project from an Existing GitHub Repo only adds a .git Directory

    When creating a new Web Project from an existing GitHub repository, Alpha Anywhere may fail to clone the repository locally if your GitHub username is incorrect, you use your GitHub password instead of a personal access token, or your personal access token lacks permissions to perform git actions against your GitHub repository.

    To resolve this issue:

    • Verify your GitHub username is correct.
    • Verify you have entered your personal access token correctly in the password. If you do not have a personal access token, follow the instructions in GitHub's documentation to create one with repo access: Creating a personal access token (external). It's recommended to use a classic personal access token at this time.
  • Push/Pull Changes to GitHub has Stopped Working

    As of August 13, 2021, GitHub no longer accepts account passwords to authenticate Git operations (push, pull). Authentication is now done using a personal access token.

    You can generate a personal access token for your account on GitHub's website. The token must have repo permissions, at a minimum, to use GitHub integration with Alpha Anywhere.

    Your personal access token is used instead of your password when configuring your saved username and password. After you have generated your token, update your Save User ID and password for GitHub. Set the password to your personal access token and save the changes. It's recommended to use a classic personal access token at this time.

  • I have a Merge Conflict for a Component. What do I do?

    Component files cannot be manually merged. In order to pull changes made a component that you've also modified, you will need to do the following:

    1. Make a copy of the component locally.

    2. Pull the modified component from the remote repository.

    3. Accept the version of the component from the remote repository, discarding all of your local changes.

    4. Commit the merge.

    5. Manually add your changes, using the component backup as a reference.

    6. Commit your changes and push them to the remote repository.

  • There may be situations where it's not possible to avoid component file merge conflicts. For example, you may be working in a branch implementing a massive UI overhaul for your next major release. In this case, the correct approach may be keeping your local changes and manually adding the modifications from the main development branch, if applicable.

    It's strongly recommended to adopt a clear policy when editing components in a team environment. This policy can be something as simple as an email notification that you're working on a file or the addition of a third-party extension or service for Git to add File Locking, such as GitLab or Git Large File Storage.

    If your entire application is contained within one file that multiple developers need to work on, consider breaking the component into multiple components.

Resources

May these resources help you in your learning journey.

Limitations

Web Projects Only

See Also