Using Git Source Control
|COMP 310 Java Resources Eclipse Resources|
Git is a popular source control system for saving and sharing one's code with other developers working on the project (i.e. have access to the shared remote repository).
Git can be run from the command line or from inside Eclipse, IntelliJ, Visual Studio and other integtrated development environments (IDE's).
GitHub is a popular cloud-based Git repository service that can be used as the remote Git repository for projects. Bitbucket is another popular cloud-based, remote Git repository service.
The Git architecture uses TWO repositories!
- Local repository -- Holds repository information on your computer's disk.
- Any data in this local repository WILL be LOST if your computer disk fails!!
- A simple "commit" will ONLY save your code to the local repository!
- The local repository is NOT shared amongst multiple developers on a project. Commits to the local repository are not accessible by other developers!
- Remote repository -- Holds repository information on a remote (e.g. cloud) system.
- Any data in this remote repository will be SAVED if your computer disk fails!!
- You must "PUSH" your code to save it to the remote repository!
- Only the remote repository is shared amongst multiple developers on a project. Code that is pushed to the remote repository is accessible by all developers on the project.
ALWAYS PUSH TO THE REMOTE REPOSITORY!!
If an Internet connection is not available, commit to the local repository but be sure to push to the remote repository as soon as Internet connectivity is re-established! This will at least enable you to recover from editing mistakes in the interim.
Other developers can't see the changes in the committed code
Make sure that the changes have been pushed all the way to the remote repository.
'submodule_folder' already exists in the index" error message
This error message can occur after removing a submodule and then trying to re-add a submodule iat the same location in the project folder hierarchy, i.e. the location indicated by '
submodule_folder'. This error can occur even after removing all references to the removed submodule from the
The problem is that Git views the removal of the submodule folder as a "staged" change and is still keeping references to it in its index. To get rid of the error and enable proceeding to add the new submodule at the same location, the folder location must be "unstaged":
- Open a terminal window at the root of the desired project.
- Eclipse: Open a "
Terminal+" view (NOT the regular "Terminal" view) because this terminal view is configured to run Git.
- To "unstage" the folder, run the following command, where the full pathname of the problematic folder relative to the project root is substituted for "submodule_folder" (i.e. the folder name as displayed in the error message):
git rm -r submodule_folder
svn:externals equivalent by having submodules track latest version: SVN:externals equivalent in Git? - Stack Overflow
Git Submodules vs Git Subtrees | Martin Owen (martowen.com)
The Rebase controversy -- spawn of the devil?
© 2021 by Stephen Wong