IDEA 将新建项目上传到git,并生成分支

bogon:mmall mac$ touch README.md

bogon:mmall mac$ touch .gitignore

bogon:mmall mac$ git init

Initialized empty Git repository in /Users/mac/IdeaProjects/mmall/.git/

bogon:mmall mac$  git status

warning: unable to access '/Users/mac/.config/git/ignore': Permission denied

On branch master

Initial commit

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        .gitignore

        README.md

        pom.xml

        src/

nothing added to commit but untracked files present (use "git add" to track)

bogon:mmall mac$ git commit -am 'first commit init project'

warning: unable to access '/Users/mac/.config/git/ignore': Permission denied

On branch master

Initial commit

Untracked files:

        .gitignore

        README.md

        pom.xml

        src/

nothing added to commit but untracked files present

bogon:mmall mac$ git add .

warning: unable to access '/Users/mac/.config/git/ignore': Permission denied

warning: unable to access '/Users/mac/.config/git/attributes': Permission denied

bogon:mmall mac$ sudo git add .

Password:

bogon:mmall mac$ git status

warning: unable to access '/Users/mac/.config/git/ignore': Permission denied

On branch master

Initial commit

Changes to be committed:

  (use "git rm --cached <file>..." to unstage)

        new file:   .gitignore

        new file:   README.md

        new file:   pom.xml

        new file:   src/main/resources/META-INF/MANIFEST.MF

        new file:   src/main/webapp/WEB-INF/web.xml

        new file:   src/main/webapp/index.jsp

bogon:mmall mac$ sudo git commit -am 'first commit init project'

[master (root-commit) 691b166] first commit init project

warning: unable to access '/Users/mac/.config/git/attributes': Permission denied

 6 files changed, 74 insertions(+)

 create mode 100644 .gitignore

 create mode 100644 README.md

 create mode 100644 pom.xml

 create mode 100644 src/main/resources/META-INF/MANIFEST.MF

 create mode 100644 src/main/webapp/WEB-INF/web.xml

 create mode 100644 src/main/webapp/index.jsp

bogon:mmall mac$ sudo git commit -am 'first commit init project'

Password:

On branch master

nothing to commit, working tree clean

//链接git远程仓库

bogon:mmall mac$ git remote add origin [email protected]:yanghui779/mmall.git

//查看分支

bogon:mmall mac$ git branch

* master

bogon:mmall mac$ git push -u origin master

The authenticity of host 'github.com (192.30.255.113)' can't be established.

RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.

Are you sure you want to continue connecting (yes/no)? y

Please type 'yes' or 'no': yes

Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

bogon:mmall mac$ git pull

Enter passphrase for key '/Users/mac/.ssh/id_rsa': 

warning: no common commits

remote: Counting objects: 5, done.

remote: Compressing objects: 100% (4/4), done.

remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0

Unpacking objects: 100% (5/5), done.

From github.com:yanghui779/mmall

 * [new branch]      master     -> origin/master

There is no tracking information for the current branch.

Please specify which branch you want to merge with.

See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

bogon:mmall mac$ git push -u -f origin master    #强制上传

Enter passphrase for key '/Users/mac/.ssh/id_rsa': 

warning: unable to access '/Users/mac/.config/git/attributes': Permission denied

Counting objects: 14, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (8/8), done.

Writing objects: 100% (14/14), 1.49 KiB | 0 bytes/s, done.

Total 14 (delta 0), reused 0 (delta 0)

To github.com:yanghui779/mmall.git

 + 9112b26...691b166 master -> master (forced update)

Branch master set up to track remote branch master from origin.

#查看远程分支

bogon:mmall mac$ git branch -r

  origin/master

#主干发布,分支开发。

#在master下创建v1.0的分支

bogon:mmall mac$ git checkout -b v1.0 origin/master

warning: unable to access '/Users/mac/.config/git/ignore': Permission denied

Branch v1.0 set up to track remote branch master from origin.

Switched to a new branch 'v1.0'

#检查下当前分支

bogon:mmall mac$ git branch

  master

* v1.0

#将分支推送到远程git

bogon:mmall mac$ git push origin HEAD -u

Enter passphrase for key '/Users/mac/.ssh/id_rsa': 

Total 0 (delta 0), reused 0 (delta 0)

To github.com:yanghui779/mmall.git

 * [new branch]      HEAD -> v1.0

Branch v1.0 set up to track remote branch v1.0 from origin.

##修改文件后,查看文件变更

localhost:mmall mac$ git status

#添加所有的新增的 修改的文件和文件夹

localhost:mmall mac$ sudo git add .   

#提交代码

localhost:mmall mac$ sudo git commit -am 'project init commit ' 

localhost:mmall mac$ git push

猜你喜欢

转载自yhgogo.iteye.com/blog/2391164