Before starting to make changes to your VS Codes locally,
please bring up VS codes, In the terminal, perform the following:
Saving Changes in VS Codes can be broken down into the following steps:
Save, Stage(add), Commit, Merge(pull), Push, Create Pull Request and Complete
1. Save: This involves clicking on the “save” or “save all” in VS Codes. This is then considered as a “modified change.". But it is not saving to git yet.
2. Add: This is to add the changes you made and saved (in modified changes) to the git staging area. You can use the following command:
· “git status”
o This will show what branch you are on and what’s modified.
· “git add <file>” or “git add .”
o You can either add one changed file to the staging area or use the shortcut “git add" to add all changes to the staging. We typically use “git add .”
o At this moment, the changes still only reside locally.
3. Commit: This is assuming all changes for a particular purpose are completed. When you do so, the system will prompt for a description of what you did. Use the format decided on by the team.
· “git commit”
This commits all changes in the staging area and commits them locally to the commit area. It will open notepad++ with some default. Delete everything. An example follows for the first line:
change CustomerRecordDefaultColumn.tsx for default screen
The first line represents the title line. Press the Enter key twice to create a blank line. Starting from the third line is the detailed description of your changes. The following are sample descriptions:
- Remove the FFL literal
- Combine City, State, Zip into one line
- Remove FFL field
Note that the description supports mark down syntax. So you can put “*” at the beginning of each line in the above examples to become bullet points.
4. View Log: This is an optional step. You can use this step to get a history of everything you changed so far before going on to the next step to merge with the server.
· “git log”
o In the log interface, use the arrow key to scroll up and down -- don’t use the scroll bar.
o Type “q” to quit review.
5. Merge: This is a recommended step that allows you to merge the latest changes from VS online if you have multiple developers working on the same project. If there’s a merge conflict, you can resolve it locally, which is much easier. If you don’t do this, then in the next step when you push your changes, it is a lot more difficult to resolve the merge conflict online.
· “git pull origin main”
o This will go to the server and download the main branch, and merge with main and the current branch (e.g., config\EMKChange).
o If it can’t merge automatically, you will have to merge it manually.
o Again, if you don't do this step, then when you try to push to the server and it has merge conflict, it is much more difficult to resolve at that point.
6. Repeat Steps 1-5 to make additional changes until you are ready to push your codes. You can choose to push one change at a time to make the process easier to operate.
7. Push: This will save the changes to the server. Use the following command:
· "git push origin <branch>"
o The <branch> may be like “config\EMKChange.”
o You can now click on the link in the terminal to go to VS online.
8. Create Pull Request: In VS online, on the right side, you will see a message something like “you just push ….” And a link to allow you create the pull request.
· The purpose of the pull request is to allow others to review your codes. It also break down the changes that will be merged to the main in a easier to manage way.
When creating the pull request, keep the title in the Description. If you only have one commit, then the description of the commit will be at the end. Keep that. If you have multiple commits, then you should combine them.
9. Complete: You can either complete it right away or wait for others to comment. Complete will merge your changes to the main branch. If you get a merge conflict, you will have to manually merge it, which is not as easy as when you merge locally.
10. Monitor: After you choose to complete, before you can pull to your local main again, you will need to wait to see if the complete is finished. You can either wait for the email notification or go to the pipeline on VS online to see the progress.
Instead of deleting local branches one by one manually, the following PS commmand is an alternative for deleting all local branches other than main:
· git branch | %{ $_.Trim() } | ?{ $_ -ne 'master' } | ?{ $_ -ne 'main'} | ?{ $_ -ne 'develop'} | %{ git branch -D $_ }
This command will get of all
branches except main locally. We do not recommend using this option.
EMK