Using Git in Engee
This example shows the basic commands of the Git version control system, which can be considered as an alternative to using Git in a file browser and command line.
Before starting work, connect the module engee_git.jl:
In [ ]:
include("$(@__DIR__)/engee_git.jl");
and navigate in the file browser to the directory where you want to perform version control.
Creating and deleting a Git repository
- Initialize the local repository in the current directory:
In [ ]:
engee_git.init();
- Clone the remote repository to the current directory:
In [ ]:
engee_git.clone_url = "git@git.engee.com:namespace/repository.git";
In [ ]:
engee_git.clone(engee_git.clone_url);
- Delete a repository from the current directory:
In [ ]:
engee_git.term();
- Link a local repository to a remote one:
In [ ]:
engee_git.remote_url = "git@git.engee.com:namespace/origin.git";
In [ ]:
engee_git.remote(engee_git.remote_url);
Changing the local repository
- Display the current repository status:
In [ ]:
engee_git.status();
Indexing changes
- Index changes to all files in the working directory:
In [ ]:
engee_git.index_add();
- Index changes to specified files:
In [ ]:
engee_git.index_add_files = "file1.txt file2.txt";
In [ ]:
engee_git.index_add(engee_git.index_add_files);
- Undo the indexing of changes to all files in the working directory, preserving their current state:
In [ ]:
engee_git.index_reset();
- Cancel indexing of changes to the specified files, saving their current state:
In [ ]:
engee_git.index_reset_files = "file1.txt file2.txt";
In [ ]:
engee_git.index_reset(engee_git.index_reset_files);
- Stop tracking changes to specified files:
In [ ]:
engee_git.index_remove_files = "file1.txt file2.txt";
In [ ]:
engee_git.index_remove(engee_git.index_remove_files);
Fixing changes
- Commit changes:
In [ ]:
engee_git.commit_message = "Initial commit";
In [ ]:
engee_git.commit(engee_git.commit_message);
- Change the last commit without changing the comment:
In [ ]:
engee_git.commit_overwrite();
- Change the last commit by overwriting the comment:
In [ ]:
engee_git.commit_overwrite_message = "New commit";
In [ ]:
engee_git.commit_overwrite(engee_git.commit_overwrite_message);
Return to the last fixed state
- Return the repository to the last committed state:
In [ ]:
engee_git.reset();
- Return the specified files to the last fixed state:
In [ ]:
engee_git.reset_files = "file1.txt file2.txt";
In [ ]:
engee_git.reset(engee_git.reset_files);
Diagnostic information output
- Display the change commit history:
In [ ]:
engee_git.log();
- Display a comparison of indexed changes with the current status of files in the working directory:
In [ ]:
engee_git.diff();
- Display a comparison of the last recorded state with indexed changes:
In [ ]:
engee_git.diff("index");
- Display a comparison of the last committed state with the current state of files in the working directory:
In [ ]:
engee_git.diff("directory");
- Display information about fixing changes with the specified hash:
In [ ]:
engee_git.commit_show_hash = "engee123456789abcdefghijklmnopqrstuvwxyz";
In [ ]:
engee_git.commit_show(engee_git.commit_show_hash);
Interacting with a remote repository
- Get changes from a remote repository:
In [ ]:
engee_git.fetch();
- Get the changes from the remote repository and merge with the current branch:
In [ ]:
engee_git.pull();
- Send the recorded changes to the remote repository:
In [ ]:
engee_git.push();
- Force the committed changes to be sent to a remote repository:
In [ ]:
engee_git.push("force");
Branching
- Display a list of repository branches:
In [ ]:
engee_git.branch_show();
- Switch to an existing branch:
In [ ]:
engee_git.branch_switch_name = "master";
In [ ]:
engee_git.branch_switch(engee_git.branch_switch_name);
- Create a new local branch:
In [ ]:
engee_git.branch_create_name = "dev";
In [ ]:
engee_git.branch_create(engee_git.branch_create_name);
- Create a new local branch and switch to it:
In [ ]:
engee_git.branch_create_switch_name = "feature";
In [ ]:
engee_git.branch_create(engee_git.branch_create_switch_name, true);
- Rename the current branch:
In [ ]:
engee_git.branch_rename_name = "main";
In [ ]:
engee_git.branch_rename(engee_git.branch_rename_name);
- Delete a branch:
In [ ]:
engee_git.branch_remove_name = "feature";
In [ ]:
engee_git.branch_remove(engee_git.branch_remove_name);
Conclusions
This example demonstrates an alternative way to work with the Git version control system in Engee.
In addition to using the Git tab in the file browser or directly entering commands into the terminal, you can sequentially run cells from this script while in the local repository.
And if necessary, you can create your own script in the same way, designed to automate work with the version control system Git.