Skip to main content

Azure-Repos-GIt-Command-Cheat-Sheet-v2

git status git add . git commit -m "commit message" git push

Basics


git fetch git merge git pull

Creating a remote repo in ADO from local repo


Setup local repo using git


  1. Create a new folder that we're going to use for this local repository
  2. Run git init in this folder in the terminal
  3. View the contents of this folder by running ls -la
  4. Run dotnet new webapp to create a new templated webapp
  5. run git status
  6. run git add . to add these
  7. Run git commit -m "Init Commit"
  8. Run git status again.

Push to?


You're probably thinking right now, yeah all we need to do is a git push

image.png

  1. Back in ADO, create a new repository for this, making sure it's an empty repo (uncheck the add a ReadMe file)
  2. You'll get an empty repo and something like this:
    image.png
  3. Back inside your terminal, run git remote and it should come up blank
  4. Run git remote add origin https://linktotherepo
  5. Then run git remote and it should come up with the origin.
  6. Run git push origin master to push the contents up to our newly created repo

Pull Requests


Git Workflow


Create new branch


Run git branch users/solo/feature1 to create a feature branch. 2. Run git branch to view the branches. 3. Run git checkout users/solo/feature1 to switch to the feature branch you created. 4. In VSCode, note that the bottom left shows the users/solo/feature1 branch 5. Change some code around in the Readme file and then commit and push using `git push origin users/solo/feature1. image.png

Create pull request


  1. Navigate to Pull Requests in the menu.
  2. Click Create Pull Request
  3. Select your new branch as the source, and the master branch as the destination to pull your branch into master. Click Complete
  4. Approve and Complete. image.png

image.png