I have a script that automates some large pull-request tasks that we do. One thing I do is to try to automatically sync two of the branches we use. I used to use a token to do a git fetch
but had to change it recently due to some policy changes.
So what I'm doing now is the below.
subprocess.check_call(['git', 'fetch', f'https://{username}:{password}@{repo_url}'], cwd=repo_path)
But, I've noticed that this doesn't always show when my local branch is out of sync with the remote branch.
Question
My question is this, what is different about git fetch
versus when I use my username, password, and repo_url that causes it not to notice remote changes when I use my username and credentials to do the fetch? What should I be doing different? And what should I be using instead to guarantee that my script notices when the remote branch is out of sync?
Further Details
I've tried scripting the git fetch all by itself, and it works just fine, only that it requires me putting in my username and password again.
subprocess.check_call(['git', 'fetch'], cwd=repo_path)