How do I push to GitHub under a different username?

后端 未结 20 2024
盖世英雄少女心
盖世英雄少女心 2020-12-02 04:00

A friend and myself are sharing my computer. I\'ve made pushes to GitHub using the git bash shell on Windows 7. Now we\'re in a different project on that computer and I need

20条回答
  •  长情又很酷
    2020-12-02 04:30

    Follow the following steps:

    1. You must understand that, you define author before commiting! the commits are already frozen: they have whatever name is set for their author and committer, and these cannot be changed.
    # you can check what's currently:
    git config user.name
    git config user.email
    
    git config user.name "your_github_username"
    git config user.email "your_github_email"
    
    # Again check what's currently:
    git config user.name
    git config user.email
    
    1. Check to whom your commit is tagged to?
    git log
    # once you're confirmed that it's tagged to you, then you should move to step 3
    

    In case, the author is wrong then you can easily undo last commit without losing changes

    Also, before moving to step3, don't forget to follow step one for sanity check.!

    1. give yourself a prompt to enter github_username and github_password
    git config --local credential.helper ""
    git push
    # it will ask you to enter your github_username and github_password
    

提交回复
热议问题