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
- Install "Git for Windows", this will be the middle man/communication service between your local instance and the Azure DevOps Repo
- https://gitforwindows.org/
- 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
- https://dev.azure.com/UniversityOfSouthDakota/
- 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
- Open "Git Bash"
- 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)
- cd <Windows Path>


- Use the following GIT command to clone the repo to your desired location/folder
- git clone https://UniversityOfSouthDakota@dev.azure.com/UniversityOfSouthDakota/SDGS%20Application%20Repo/_git/SDGS%20Application%20Repo .
- 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"

- 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
- git status (Note I have seen where this doesn't always work 100%, you may need to run 'git fetch' then 'git status')

- 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"


- Since the changes are local the REPO hasn't been changed and doesn't contain the changes

- To push these changes to DevOps you need to ADD, COMMIT and PUSH the changes
- git add . (Add all local changes)
- git commit -m '' (A message must be added to a commit, make it descriptive)
- git push (Pushes the changes)


- Learn GIT
- https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F
- 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
- Example
- Developer A makes changes to the file and pushes those changes to the remote repository
- Developer B also makes changes to the same file but hasn't pulled the latest changes from the remote repository yet
- When Developer B tries to push their changes:
- 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).
- 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"
- Developer B must pull the latest changes from the remote repository
- They will need to run git pull to fetch the changes made by Developer A and merge them with their own local changes
- 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
- 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