Git Tips - dibley1973/OpenRMS GitHub Wiki
Git Tips
This page covers some tips for anyone new to using the GIT tools in visual studio.
Visual Studio Team Explorer Cheat Sheet
Staging / Un-staging changes ready for committing
After making changes to code which you now want to commit, in Team Explorer go to Home > Changes.
- To add files to your commit commit, right click the files and select Stage.
- To remove files to your commit commit, right click the files and select Unstage.
Committing changes locally
Once the correct files are staged, you can commit them locally. In Team Explorer go to Home > Changes, add a commit comment and dont forget to link the comment with the issue using the # notation. For example:
Renamed `Entity` directory to `BaseClasses` and changed child file namespaces. #37
Then click Commit Staged button to commit your changes locally.
WARNING! DO NOT then click the "Sync" hyperlink in the Changes window, for example...
Commit 2a17e830 created locally. Sync to share your changes with the server.
...as this will push your changes STRAIGHT to the server and merge them with any changes already on the server which you have not yet picked up, without compiling them! You must fetch any changes from the server and merge them with your on your changes on your machine first! See Pushing your changes to the server
Seeing your local commits
In Team Explorer go to Home > Sync, and look for entries in Outgoing Commits.
Pushing your changes to the server
Before pushing your outgoing commits, you must first retrieve any changes from the server and fix merge issues. To do this:
- In Team Explorer go to Home > Sync
- Perform a Fetch to see what changes are on the server in Incoming Commits
- Perform a Pull the changes in Incoming Commits
- Make any fixes you need, build, run tests, etc.
- Re-stage your changes (if any occurred)
- Re-commit locally
- Then return to Step 2 and repeat until no incoming commits are found.
- Quickly Push your commits to the server.
This process ensures that any merges that happen happen on YOUR MACHINE and you take the responsibility to fix merge issues before committing changes to the server. If there are a lot of team members making regular pushes than you may need to go round the Fetch-Pull-Fix-Stage-Fetch loop a few times until no incoming commits are encountered.
Git Command Line Cheat Sheet
T.B.C.