Committing
Last updated
Last updated
A commit is the basic operation of Git version history. It is basically a local snapshot of your repository at a particular point in time. It's a good idea to create new commits frequently, similar to saving changes as you write a document. You can choose to Push these commits to the server at any time.
Copia has a 2gb max file size for pushing files to the server. This means you should not commit any files over 2gb in your repository.
A commit includes a commit message and description of the change, along with information about when the change occurred and who made it.
There are two sections in this topic:
We will start with Committing in the Web App, but click the link above to jump to the Desktop App section if needed.
From the Dashboard, navigate to the repository you want to add a file to. Click on the New File button.
On the next screen, you can name your new file. This will be added to the repository.
Scroll down to the bottom of the screen to commit your file. At this point, you can choose whether to commit the file to main
or to create a new branch for this file.
Click Commit Changes to finish creating your file.
From the Dashboard, navigate to the repository you want to upload a file to. Click the Upload File button.
Add a directory name for the uploaded file. Then drag and drop your file into the upload field, or click on the box to browse and select the file you wish to upload.
Scroll down to add an optional description of the file you have uploaded and commit your file to the directory you have chosen. At this point, you can choose whether to commit the file to main
or to create a new branch for this file.
Click Commit Changes to finish creating your file.
Click Show in Explorer to manage your local repository.
Your file manager will display all the contents of your repository. You can make changes to your file, rename it, or delete it entirely. When you reopen the Desktop App, you will be presented with the reflected change(s) in the Changes tab.
If you don't see your changes reflected in the Copia Desktop App, first make sure that you successfully saved your file.
If you realize you made a mistake, you can always discard your changes prior to committing them. To do this, navigate to the Changes tab, right-click on the change you wish to discard, and select the Discard changes... option.
Discarding changes will change the local file on your computer back to the previous version. Ensure that you are certain of this before discarding changes.
Copia recommends that you perform file renames separate from file changes. This is because Git only infers a rename operation based on whether a newly added file is similar to another file that was deleted. Simultaneously making changes and renaming in a single commit may result in the end of one file history and the start of a new one.
Commits are often used to mark significant changes that you might want to look back on. You can think of them as meaningful, local changes that you can choose to store as a checkpoint. All commits you make will appear in the version history.
Commits that are especially significant can be used to create a tag. To learn more, check out the Tags and Releases section.
Once you're ready to commit in the Desktop App, navigate to the Changes tab and fill in the Summary and Description fields with information that outlines the changes reflected in that commit. The Description field is optional.
If you'd like to add a Co-Author to the commit, click on the icon in the lower left of the Description field. You might do this in certain use-cases where two engineers are working on code, but only one is saving changes to Copia. This allows you to attribute code changes to multiple users for future reference.
Press the Commit to main button. This will store your change locally. You can make multiple changes and commit them before moving on.
While you can commit a single change and push it to remote, it's quite common to make multiple meaningful commits on your local branch and then push. To learn more about pushing commits, check out the Pushing section.
If you need to update a commit message or if you forgot to include changes in your commit, you might want to amend your commit. This action updates the most recent commit you have made in your current branch, prior to pushing the change.
To amend a commit, navigate to the History tab and right click on the most recent commit.
If you wanted to include additional changes, make them prior to amending the commit.
Update the Summary and Description fields to clarify the reason for the amend. Be sure to check any uncommitted changes that you would like to add to the commit. When finished, click the Amend last commit button.
You cannot amend a commit if you have already pushed a change. Doing so would alter the history on the Copia server and cause confusion for others who may have already pulled these changes.
In addition to amending a commit, you might want to revert a specific change. This allows you to remove that change from the top of the main branch.
Navigate to the History tab, right-click the commit you want to revert, and choose the Revert Changes in Commit button.
If you experience issues with reverting, first ensure that your IDE is closed.
Push the revert to remote by clicking the Push button. You can learn more about pushing in the next section.
You can only perform a revert after pushing if no subsequent commits have been performed.
If you require more guidance, we recommend that you review our video on reverting:
If you would like to access the files of a previous commit, you can use the Checkout Commit feature.
Before using this feature, make sure that you don't have any repository files open. Click into the History tab, right click on your commit, and select the Checkout commit option.
When you select this option, you revert to an older commit, meaning that your repository files and commit history will be temporarily reverted to the prior state. This state in Git is called a "Detached HEAD" and is treated as a temporary local branch. At this point, you can access your local repository and it will reflect the files at that commit point.
You can use this method to revert files to a prior state (or just for review) by either:
Making a copy of those files to later commit
After copying the files to another location, you can cancel the Checkout by just switching back to the Main branch from the dropdown.\
Creating a new Branch from the Detached Head and merging
In the Branch dropdown, select the "New Branch" option, which will use the Detached HEAD as the revision for the new branch
To cancel the entire Checkout operation, simply switch back to the Main branch from the Branch dropdown.
If you require more guidance, we recommend that you review our video on commit checkout:
If you would like to restore the files of a previous commit, you can use the Restore from Commit feature.
Click into the History tab, right-click on your commit, and select the Restore from Commit option.
If you already had changes in your working directory (i.e. your local repository folder), the Desktop App will warn you before overwriting those changes.
Once complete, the restore operation will update your local repository with the files from that previous commit. Navigate to the Changes tab and provide information for the Summary and Description fields. Once ready, press the Commit button. Your new commit will be reflected in the History tab.
We recommend that you incorporate the SHA and date of the prior commit into the commit message for traceability.