git bash : how to check if there's a new commit available

前端 未结 2 1901
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 17:40

I use git with my friend to collaborate on a project. He created a repo in github consisting folders of each of our names, so everytime i update something, I upload it to th

2条回答
  •  心在旅途
    2020-12-06 18:24

    If your branch is properly tracking the remote branch, you should be able to do a git status and see if you're ahead or behind the remote and by how many commits.

    This was a little confusing about git for me. Here's the answer in three parts:

    1) Usually when you clone a remote repo, you need the -t flag to track the remote branch you're copying:

    git checkout -tb my_branch origin/my_branch
    

    2) If you forget to do this, you can always do this later by doing:

    git branch --set-upstream my_branch origin/my_branch
    

    3) If your remote branches are the same name as your local branchesyou should be able to just set git to track all remote branches automatically:

    git config push.default matching             <-- for this repo only
    git config --global push.default matching    <-- for all git repos that this user deals with on this machine
    

    For your second question, yes that should be fine as long as you're using the same user on your machine. Git uses SSH authentication so it doesn't matter where the repo is located as long as the right user is running the command so it sends the proper SSH credentials along with the request.

提交回复
热议问题