在合适的位置创建自己版本库!
什么是版本库呢?版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改、删除,Git都能跟踪,以便任何时刻都可以追踪历史,或者在将来某个时刻可以“还原”。
第一步:创建一个版本库非常简单,首先,选择一个合适的地方,创建一个空目录:
第二步:通过git init命令把这个目录变成Git可以管理的仓库
瞬间Git就把仓库建好了,而且告诉你是一个空的仓库(empty Git repository),细心的读者可以发现当前目录下多了一个.git的目录,这个目录是Git来跟踪管理版本库的,没事千万不要手动修改这个目录里面的文件,不然改乱了,就把Git仓库给破坏了。
如果你没有看到.git目录,那是因为这个目录默认是隐藏的,用ls -ah命令就可以看见。
在workspace中创建一个新的hello.txt文本
之后把文本 加入到 git的管理中
git status命令可以列出当前目录所有还没有被git管理的文件和被git管理且被修改但还未提交(git commit)的文件.。
告诉 git 我们提交了 文件
初次运行 Git 前的配置
一般在新的系统上,我们都需要先配置下自己的 Git 工作环境。配置工作只需一次,以后升级时还会沿用现在的配置。当然,如果需要,你随时可以用相同的命令修改已有的配置。
用户信息
第一个要配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录:
因为上面clone的时候 是使用的https协议 所以 每次提交的时候都会提示 输入用户名和密码!
按 i o a 都可以进入编辑状态
编辑中 :切换到 底行模式! 之后 :wq! 保存退出 即可!
重新 启动 Git Bash即可!
如果第一次克隆失败 是因为 没有在自己的git上配置sshkey!
继续下面的操作
打开文件,复制 内容
文件夹下面会多一个
如果是把本地的仓库发布到git上,会遇到下面的问题
执行下列代码会解决问题
Myeclipse安装egit插件
打开 创建一个git文件夹
把下载的egit压缩文件解压到git文件夹下 即可!
然后重启myeclipse
解决办法
返回上一步 选择 Force Update
小豆腐@admin MINGW64 /e/workGit
$ git init
Initialized empty Git repository in E:/workGit/.git/
小豆腐@admin MINGW64 /e/workGit (master)
$ pwd
/e/workGit
小豆腐@admin MINGW64 /e/workGit (master)
$ ls
小豆腐@admin MINGW64 /e/workGit (master)
$ ls -a
./ ../ .git/
小豆腐@admin MINGW64 /e/workGit (master)
$ ls
hello.txt
小豆腐@admin MINGW64 /e/workGit (master)
$ gid add hello.txt
bash: gid: command not found
小豆腐@admin MINGW64 /e/workGit (master)
$ git add hello.txt
小豆腐@admin MINGW64 /e/workGit (master)
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: hello.txt
小豆腐@admin MINGW64 /e/workGit (master)
$ git commit -m"我刚刚提交了一个hello.txt文件";
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <С▒▒▒▒@admin.(none)>) not allowed
小豆腐@admin MINGW64 /e/workGit (master)
$ git config --global user.email "501804292@qq.com"
小豆腐@admin MINGW64 /e/workGit (master)
$ git config --global user.name "XiaoDouFu"
小豆腐@admin MINGW64 /e/workGit (master)
$ git commit -m"我刚刚提交了一个hello.txt文件";
[master (root-commit) 623dd73] 我刚刚提交了一个hello.txt文件
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
小豆腐@admin MINGW64 /e/workGit (master)
$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=E:/myGit/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.email=501804292@qq.com
user.name=XiaoDouFu
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
小豆腐@admin MINGW64 /e/workGit (master)
$ git clone https://git.oschina.net/jpwy999/test.git
Cloning into 'test'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
小豆腐@admin MINGW64 /e/workGit (master)
$ cd test
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git add hello.txt
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git commit -m"从我本地上第一次上传"
[master 8727f9e] 从我本地上第一次上传
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git pull --rebase origin master
From https://git.oschina.net/jpwy999/test
* branch master -> FETCH_HEAD
Current branch master is up to date.
小豆腐@admin MINGW64 /e/workGit/test (master)
$ ssh-keygen -t rsa -c "501804292@qq.com"
Too many arguments.
usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa | rsa1]
[-N new_passphrase] [-C comment] [-f output_keyfile]
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
ssh-keygen -i [-m key_format] [-f input_keyfile]
ssh-keygen -e [-m key_format] [-f input_keyfile]
ssh-keygen -y [-f input_keyfile]
ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]
ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]
ssh-keygen -B [-f input_keyfile]
ssh-keygen -D pkcs11
ssh-keygen -F hostname [-f known_hosts_file] [-l]
ssh-keygen -H [-f known_hosts_file]
ssh-keygen -R hostname [-f known_hosts_file]
ssh-keygen -r hostname [-f input_keyfile] [-g]
ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point]
ssh-keygen -T output_file -f input_file [-v] [-a rounds] [-J num_lines]
[-j start_line] [-K checkpt] [-W generator]
ssh-keygen -s ca_key -I certificate_identity [-h] [-n principals]
[-O option] [-V validity_interval] [-z serial_number] file ...
ssh-keygen -L [-f input_keyfile]
ssh-keygen -A
ssh-keygen -k -f krl_file [-u] [-s ca_public] [-z version_number]
file ...
ssh-keygen -Q -f krl_file file ...
小豆腐@admin MINGW64 /e/workGit/test (master)
$ ssh-keygen -t rsa -C "501804292@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/小豆腐/.ssh/id_rsa):
Created directory '/c/Users/小豆腐/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/小豆腐/.ssh/id_rsa.
Your public key has been saved in /c/Users/小豆腐/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ys8ogLtlMT6ea8H9k5C8MvQxdOu57oi+eyVVJIFkkHg 501804292@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| ..+o.oo. |
|. E.. .. |
| . . |
| . o |
| oo+ + .S |
|..=oO.o. |
| o=+ Xoo |
|.+++=.*+ |
|.+OB.+=oo |
+----[SHA256]-----+
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git pull --rebase origin master
From https://git.oschina.net/jpwy999/test
* branch master -> FETCH_HEAD
Current branch master is up to date.
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git push origin master
fatal: Authentication failed for 'https://git.oschina.net/jpwy999/test.git/'
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 323 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://git.oschina.net/jpwy999/test.git
4f99553..8727f9e master -> master
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git add hello.txt
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git commit -m"我上传我喜欢"
[master a1d6641] 我上传我喜欢
1 file changed, 1 insertion(+), 1 deletion(-)
小豆腐@admin MINGW64 /e/workGit/test (master)
$ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://git.oschina.net/jpwy999/test.git
8727f9e..a1d6641 master -> master
小豆腐@admin MINGW64 /e/workGit/test (master)
$