1.首先在本地创建ssh key;
ssh-keygen -t rsa -C "your_email@youremail.com"
2.接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。
git config --global user.name "liutizhong"
git config --global user.email "liutizhong@163.com"
3.创建
mkdir ProjectTest
cd ProjectTest
git init
touch Readme
git add Readme
git commit -m 'first commit'
git remote add origin git@DX2:liutizhong/projecttest.git
git push -u origin master
遇到的问题:
To https://name@bitbucket.org/name/mywork.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://name@bitbucket.org/name/mywork.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
原因:由于远程仓库中代码版本与本地不一致冲突导致的。
git pull origin master
2.如何将maven创建的工程git到gitlib上
先在gitlib新添加一个工程
git config --global user.name "liutizhong"
git config --global user.email "liutizhong@163.com"
mkdir ProjectTest
cd ProjectTest
git init
touch Readme
git add Readme
git commit -m 'first commit'
git remote add origin git@DX2:liutizhong/projecttest.git
git push -u origin master
然后再在linux指定目录下执行 git clone 操作,将刚建好的git工程在改目录下clone下来
将maven生成的Eclipse工程拷贝到 刚刚clone 的目录下 执行
git add .
git commit -m 'submit project'
git push origin master
完成操作!