We use Azure Repos as source control in our project. A developer has created a branch named "testBranch" and gave access to the team so everyone can push to that branch. What are the correct git commands for team members to push their changes to "testBranch"?
Asked
Active
Viewed 36 times
2 Answers
0
Before a push make sure every developer pulls changes pushed by others first. To do so:
git pull origin testBranch
You may get to see merged changes, or conflicts. Depending on your choice of editor for conflict resolution, you should be able to resolve conflicts locally.
Now you can add and commit locally all the files you need to push by :
git add filename.py
git commit -m "changes made for so and so module"
now you can happily push the changes
git push origin testBranch
You can also set upstream branch when you know you need to make multiple pushes or pulls.
git branch --set-upstream-to testBranch
This will trim down your pull and push commands to not having to mention "origin testBranch"

Shruti Kar
- 147
- 1
- 12
-
We get this when pushing to testBranch **$ git push origin testBranch error: src refspec testBranch does not match any.** – L_A_Hooper Aug 21 '20 at 14:13
-
This may help you : https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git – Shruti Kar Aug 21 '20 at 14:29
-
Unfortunately it is not. We have master branch and it works one. What we are looking at is how to work on a coworker branch which already has some commits. – L_A_Hooper Aug 21 '20 at 14:42
0
We were missing HEAD in the command. This did the trick:
git push origin HEAD:testBranch

L_A_Hooper
- 81
- 1
- 9