Azure DevOps Repo How To

Summary

How do I get the current code base from the Azure DevOps Repo
How can I push changes to the Azure DevOps Repo

Body

Issue/Question

How do I get the current code base from the Azure DevOps Repo

How can I push changes to the Azure DevOps Repo

Environment

  • Windows GIT
  • Azure DevOps Repo

Cause

There are many reasons a user would want to pull current code or push new code to our Azure DevOps Repo

Resolution

USD STAFF ONLY

  1. Install "Git for Windows", this will be the middle man/communication service between your local instance and the Azure DevOps Repo
    1. https://gitforwindows.org/
  2. The DevOps Repo can be found here. There are multiple Repos so you may need to look for the specific one where your code exists
    1. https://dev.azure.com/UniversityOfSouthDakota/
  3. Below will be an example of going about cloning a repo, checking your local codes status and finally pushing and pulling. I'll be using the "SDGS" repo in this overview
  4. Open "Git Bash"
  5. Navigate (cd) to the folder location where you want to store your project on your machine. (In this example I've created a SDGS folder within my desktop)
  6. cd <Windows Path>
    1. Uploaded Image (Thumbnail)
    2. Uploaded Image (Thumbnail)
  7. Use the following GIT command to clone the repo to your desired location/folder
  8. git clone https://UniversityOfSouthDakota@dev.azure.com/UniversityOfSouthDakota/SDGS%20Application%20Repo/_git/SDGS%20Application%20Repo .
    1. Type the following with the "." at the end if you want to get the files within the repo and not download the folder where the files exist. Otherwise your clone will come down as "SDGS%20Application%20Repo"
    2. Uploaded Image (Thumbnail)
  9. Now you have a local copy of the files currently within the repository. You can run the following to check status at any time to check you files against the main repo
    1. git status (Note I have seen where this doesn't always work 100%, you may need to run 'git fetch' then 'git status')
    2. Uploaded Image (Thumbnail)
  10. If you have changes the "git status" will look differently, here is an example when I updated the README.md file with the following text "#Update Example"
    1. Uploaded Image (Thumbnail)
    2. Uploaded Image (Thumbnail)
  11. Since the changes are local the REPO hasn't been changed and doesn't contain the changes
    1. Uploaded Image (Thumbnail)
  12. To push these changes to DevOps you need to ADD, COMMIT and PUSH the changes
    1. git add .           (Add all local changes)
    2. git commit -m ''  (A message must be added to a commit, make it descriptive)
    3. git push         (Pushes the changes)
    4. Uploaded Image (Thumbnail)
    5. Uploaded Image (Thumbnail)
  13. Learn GIT
    1. https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F
  14. Not paying attention can really cause repos to become chaotic, please keep each other informed so you're not working in the same files and pushing over each other. This will cause discrepancies that need to be merged or corrected and its a headache to correct
  15. Example
    1. Developer A makes changes to the file and pushes those changes to the remote repository
    2. Developer B also makes changes to the same file but hasn't pulled the latest changes from the remote repository yet
    3. When Developer B tries to push their changes:​​​​​​
    4. Git will detect that the remote repository has changes that Developer B does not have in their local copy (because Developer A already pushed their changes).​​​​​​
    5. Git will reject Developer B's push with an error message, typically something like "rejected because the remote contains work that you do not have locally"
    6. Developer B must pull the latest changes from the remote repository
    7. They will need to run git pull to fetch the changes made by Developer A and merge them with their own local changes
    8. If there are any conflicts between Developer A's changes and Developer B's changes, Git will prompt Developer B to resolve these conflicts manually
    9. Once Developer B resolves any conflicts (if there are any), they can commit the merged changes and then push the combined result back to the remote repository

Details

Details

Article ID: 9341
Created
Fri 10/18/24 11:34 AM
Modified
Mon 6/23/25 10:11 AM
KCS Article Status
WIP: Only Problem & some Environment captured
Not Validated: Complete & Resolution captured, confidence lacks in structure, content, no feedback
Validated: Complete & reusable, used by licensed KCS user, confidence in resolution & std. compliance
Validated