| Date and time note was created | $= dv.current().file.ctime |
| Date and time note was modified | $= dv.current().file.mtime |
If you have one commit on the remote repository and non-tracked changes locally, you’ll want to handle this situation carefully to ensure that you don’t lose any important changes. Here’s a step-by-step guide on what to do:
-
Stash Your Local Changes (Optional but Recommended): If you have uncommitted changes in your local working directory that you want to keep but not include in the next commit, you should stash them. Stashing allows you to save your changes temporarily and apply them later.
To stash your changes, use the following commands in your terminal:
git stash save "Your stash message"Replace
"Your stash message"with a descriptive message about what you’re stashing (e.g., “Work in progress” or “Temporary changes”). -
Fetch the Latest Changes from the Remote Repository: Fetching updates the information about the remote repository without merging or applying any changes to your local branch. It’s essential to know if there have been any changes on the remote since your last fetch.
Run the following command to fetch the latest changes:
git fetch originReplace
originwith the name of your remote if it’s different. -
Check the Status and View the Differences: After fetching, you should check the status of your local branch to see if there have been any updates on the remote branch. You can use:
git statusIt will display information about your local branch compared to the remote branch.
-
Rebase or Merge (Choose One): Now, you have two options:
a. Rebase: If you want to keep your local changes on top of the remote commit (making a linear history), you can use rebase. This is the preferred option if you have only one commit on the remote.
git rebase origin/mainReplace
mainwith the name of your remote branch if it’s different.b. Merge: If you prefer to create a merge commit that combines your local changes and the remote commit, you can use merge.
git merge origin/mainAgain, replace
mainwith the appropriate remote branch name. -
Apply Stashed Changes (If Stashed): If you stashed your changes earlier, you can now apply them:
git stash applyThis will reapply your stashed changes on top of the rebased or merged branch.
-
Resolve Conflicts (If Any): If there are conflicts between your stashed changes and the remote changes, Git will prompt you to resolve them. Manually edit the conflicting files to resolve the conflicts, then add and commit the resolved files.
-
Push the Changes to Remote: Finally, push your changes to the remote repository:
git push origin mainReplace
mainwith your branch name if it’s different.
Now, your local branch should be up to date with the remote, and any stashed changes should be applied on top of it.