Git 使用小记

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容