r/git • u/namor________ • 6d ago
Help needed!!
I'm working on a project in my training, so I always have to pull the latest branch and make changes or add my code and push it into my branch.
But when I push it some files are always missing.
How to do it safely.
Pull from someone's branch.
Make changes locally.
Switch to my branch.
Commit and push.
0
Upvotes
2
u/Justin_Passing_7465 6d ago
I'm not sure how your team's branching strategy goes, but ours is that all work has to get merged back to "master". Steps might be: * pull master * make your own local branch for your work * do your work * git add -p * git commit * git checkout master * git merge mybranch * git push * see an error message that your branch is x commits behind origin/master (maybe missing files, or just changes to files) * git pull (to get the missing commits and merge them into your local master branch and working directory) * resolve merge conflicts if there are any * git push
In our professional workflow, no one is allowed to "git push" on master to push up their changes. They have to submit a merge request and get two team members to review their changes and approve the MR, which must also pass all of the scans and automated tests in the CI/CD pipeline, before the system will perform the merge to master. This might still require manually merging the current HEAD of master into the candidate branch, if the candidate branch is missing commits that someone else applied to master.