美文网首页
Git 使用小记

Git 使用小记

作者: 坚果牛奶 | 来源:发表于2019-04-04 12:12 被阅读0次

    Ignore idea folders
    git rm -r --cached .idea

    Merge a branch into master branch in GitHub
    git checkout master
    git pull origin master
    git merge $YourBranchName$
    git push origin master

    Sometimes when you try to pull or merge code, the git bash may occur the screen to ask you to enter a commit message. The message may say "Please enter a commit message to explain why this merge is necessary."
    solution:

    • If you do not want to enter any message for this pull or merge:
      1. pressEsc.
      2. press:+w+q and then press Enter.
    • If you want to enter a message for it:
      1. Press i.
      2. Input your message.
      3. PressEsc.
      4. press:+w+q and then press Enter.

    If you have pushed your code before you ignore some folders when you try to pull, you may get the message like this: "The following untracked working tree files would be overwritten by checkout"
    solution:
    git fetch --all
    git reset --hard origin/{branch_name}

    If you changed your local code and have not committed it, but you want to pull the update from the remote repository, you may get the error message "Your local changes to the following files would be overwritten by merge"
    solution:
    git stash
    git pull origin master
    git stash pop

    To add .gitignore file(windows下添加.gitignore文件):
    touch .gitignore
    Ignore all .pyc files in git repository(忽略所有.pyc文件):
    add a line to the .gitignore file
    *.pyc

    相关文章

      网友评论

          本文标题:Git 使用小记

          本文链接:https://www.haomeiwen.com/subject/mndfiqtx.html