Skip to content

Instantly share code, notes, and snippets.

@eddy1982
Last active August 29, 2015 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddy1982/2c3bff32e0118775cd4e to your computer and use it in GitHub Desktop.
Save eddy1982/2c3bff32e0118775cd4e to your computer and use it in GitHub Desktop.
$ git remote add origin https://github.com/eddy1982/sql.git
$ git remote set-url https://github.com/eddy1982/sql.git
$ git remote remove origin
$ git remote -v
$ git push origin master
強制修改上一次的commit
$ git commit --amend -m ''
$ git push <remote> <branch> -f
新開一個repo完整的步驟:
1. 先去該資料夾, 右鍵Git Bash here
2. git config user.name [檢查使用者]
3. git init
4. git add *.c [開始加入需要的檔案]
5. git commit -m 'initial project version'
5-1. 如果要clone下來就
$ git clone https://github.com/libgit2/libgit2
如果要clone下來又新開一個資料夾
$ git clone https://github.com/libgit2/libgit2 mylibgit
6. git status
7. 新增.gitignore
教學如下:
# no .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the root TODO file, not subdir/TODO
/TODO
# ignore all files in the build/ directory
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .txt files in the doc/ directory
doc/**/*.txt
8. git log
9. git commit --amend [強制刪掉上一個commit]
10. 設定remote (github)
10-1. 這時在github開一個repo, 名字取跟localhost的資料夾一樣
10-2. git remote -v [檢查所有remote]
10-3. git remote add origin https://github.com/paulboone/ticgit [新增]
10-4. git fetch origin
10-5. git pull origin master
10-6. git push origin master
如果要砍掉所有git記錄
http://stackoverflow.com/questions/15244644/how-to-restart-a-git-repository
rm -rf .git
git init .
git ls-files -o
忽略某個檔案, 但要先push上去, 記得先把密碼換成假的
git update-index --assume-unchanged [filename]
執行完後, 再打上新的帳密
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment