1、创建一个新的文件夹,并进入到该文件夹里,使用命令:git init来创建新的git仓库;
2、获取钩子(每次git init之后都要一次):
[[email protected] activity.mycihi.cn]#
scp -p -P 8849 [email protected]:hooks/commit-msg .git/hooks/
Enter passphrase for key ‘/root/.ssh/id_rsa‘:
commit-msg 100% 4365 4.3KB/s 00:01
3、从远程仓库中把代码克隆到本地,检出仓库:
本地仓库的克隆:git clone /path/to/repository
远程仓库的克隆:git clone [email protected]:/path/to/repository
如:
[[email protected] activity.mycihi.cn]# git clone ssh://[email protected]:8849/activity
Initialized empty Git repository in /http/activity.mycihi.cn/activity/.git/
Enter passphrase for key ‘/root/.ssh/id_rsa‘:
remote: Counting objects: 3082, done
remote: Finding sources: 100% (3082/3082)
remote: Total 3082 (delta 1140), reused 3031 (delta 1140)
Receiving objects: 100% (3082/3082), 13.35 MiB | 676 KiB/s, done.
Resolving deltas: 100% (1140/1140), done.
4、创建分支:git branch ‘分支名称’
5、添加到缓存区:git add <filename>
6、提交到本地版本库:git commit -m "代码提交信息"
7、推送到远程版本库:git push origin master
git push origin HEAD:refs/for/develop
$ makdir ~/hello-world //创建一个项目hello-world
$ cd ~/hello-world //打开这个项目
$ git init //初始化
$ touch README
$ git add README //更新README文件
$ git commit -m ‘first commit‘ //提交更新,并注释信息“first commit”
$ git remote add origin [email protected]:defnngj/hello-world.git //连接远程github项目
$ git push -u origin master //将本地项目更新到github项目上去