To create a new branch for your task in Azure DevOps, follow these steps:
-
Using the Azure DevOps Web Interface:
- Go to your repository in Azure DevOps.
- Click on the "Branches" tab.
- Find the branch you want to base your work on (usually
main
or another feature branch). - Click the "New branch" button.
- Give your branch a descriptive name (e.g.,
feature/your-task-name
). - Start working on your task in this new branch.
-
Using Git Command Line:
git checkout -b feature/your-task-name origin/main
This creates a new branch based on
main
and switches to it.
-
Forking:
- Creating a fork makes a copy of the entire repository into your own account.
- Useful when you don't have write access to the original repository.
- Typically used for open-source contributions or when working independently.
- Changes are contributed back via pull requests from your fork to the original repository.
-
Creating a Branch:
- Creating a branch keeps your work within the same repository.
- You have full access to the repository (if you have permissions).
- Useful for collaborative work within the same team.
- Changes are merged back into the main branch via pull requests.
-
Creating a Sub-Branch:
- Ensure you are on your main task branch:
git checkout feature/your-task-name
- Create a new branch for additional work:
git checkout -b feature/your-task-name-subtask
- Do your work and commit changes in this sub-branch.
- Ensure you are on your main task branch:
-
Merging Back:
- Switch back to your main task branch:
git checkout feature/your-task-name
- Merge the sub-branch into your main task branch:
git merge feature/your-task-name-subtask
- Resolve any conflicts if they arise.
- Delete the sub-branch:
git branch -d feature/your-task-name-subtask
- Switch back to your main task branch:
-
Submitting a Pull Request:
- Once all your work is merged into
feature/your-task-name
, go to Azure DevOps. - Create a pull request from
feature/your-task-name
to the target branch (usuallymain
). - Review your changes and submit the pull request for approval.
- Once all your work is merged into
If you want to add changes to the staging area (index) without committing them, you can use:
git add .
This stages all changes, but doesn't commit them. You can then commit when you're ready:
git commit -m "Your commit message"
If you want to stage only specific files or parts of files, you can use:
git add <file-name>
Or use git add -p
to stage changes patch by patch.
Remember, staging changes is a way to prepare a commit, but nothing is saved to the history until you commit.