$ git config credential.helper store
$ git push https://github.com/repo.git(你的git倉庫地址)
Username for 'https://github.com': <USERNAME>
Password for 'https://USERNAME@github.com': <PASSWORD>
如果是在其他電腦上使用,還可以使用緩存期進行設置到期時間
git config --global credential.helper 'cache --timeout 7200'
單位是秒,7200秒(2個小時)后失效