這里對git init、git add、git commit命令進(jìn)行一個總結(jié)。 $ git init 命令,該命令將創(chuàng)建一個名為 .git 的子目錄,這個子目錄含有你初始化的 Git 倉庫中所有的必須文件;
$ git add 命令,該命令用于把我們要提交的文件的信息添加到遠(yuǎn)程庫中;
$ git commit 命令,該命令用于把推送修改到本地庫中。
例子:
1.git init
Initializes a new local Git repository.
- Initialize a new local repository:
git init
- Initialize a barebones repository, suitable for use as a remote over ssh:
git init --bare
2. git add
Adds changed files to the index.
- Add a file to the index:
git add path/to/file
- Add all files (tracked and untracked):
git add -A
- Only add already tracked files:
git add -u
- Also add ignored files:
git add -f
- Add parts of a file interactively:
git add -p path/to/file
3.git commit
Commit files to the repository.
- Commit staged files to the repository with a message:
git commit -m message
- Replace the last commit with currently staged changes:
git commit --amend
- Auto stage all modified files and commit with a message:
git commit -a -m message
上傳到git hub更新
首先進(jìn)入到我們要上傳的目錄 比如 cd demo1
git init
創(chuàng)一個html文件 touch index.html
接下來將這個文件
git add index.html
然后 git commit .m “標(biāo)題”
git pull
git push