0%

Git命令收集

能放出来的都放出来,在一个地方比较好管理,自己碰到的几个常用命令吧。

  1. 使用
    1. 已经追踪的文件,后面放到ignore里了,如何处理
    2. 迁移 bitbucket 到 github
  2. 参考

使用

已经追踪的文件,后面放到ignore里了,如何处理

.gitignore will prevent untracked files from being added (without an add -f) to the set of files tracked by git, however git will continue to track any files that are already being tracked.

To stop tracking a file you need to remove it from the index. This can be achieved with this command.

git rm --cached <file>

If you want to remove a whole folder, you need to remove all files in it recursively.

git rm -r --cached <folder>

The removal of the file from the head revision will happen on the next commit.

WARNING: While this will not remove the physical file from your local, it will remove the files from other developers machines on next git pull.

迁移 bitbucket 到 github

这里可以用官方的 GitHub Desktop 来偷懒不用提前创建好 GitHub 上的仓库。
GitHub Desktop 可以直接帮你 push 创建。


cd $HOME/Code/repo-directory
git remote rename origin bitbucket
git remote add origin https://github.com/xxx/xxx.github.io.git
git push origin master

git remote rm bitbucket

参考

How to make Git “forget” about a file that was tracked but is now in .gitignore?