在 Linux 上:
$ cd /home/user/my_project
在 MacOS 上:
$ cd /Users/user/my_project
在 Windows 上:
$ cd C:\Users\user\my_project
之后执行:
$ git init
$ git add *.c
$ git add LICENSE
$ git commit -m 'Initial project version'
$ git clone <url>
还不会使用 GitHub ? GitHub 教程来了!万字图文详解
$ git config --global usr.name <name>
$ git config --global usr.email <email>
$ git config --list --show-origin
$ git remote
$ git fetch
$ git pull
$ git push
$ git branch
$ git checkout
$ git diff
$ git merge
Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur. There are two groups of these hooks: client-side and server-side. Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits. You can use these hooks for all sorts of reasons.
和其它版本控制系统一样,Git 能在特定的重要动作发生时触发自定义脚本。 有两组这样的钩子:客户端的和服务器端的。 客户端钩子由诸如提交和合并这样的操作所调用,而服务器端钩子作用于诸如接收被推送的提交这样的联网操作。 你可以随心所欲地运用这些钩子。
A remote repository is generally a bare repository — a Git repository that has no working directory. Because the repository is only used as a collaboration point, there is no reason to have a snapshot checked out on disk; it’s just the Git data. In the simplest terms, a bare repository is the contents of your project’s .git directory and nothing else.
一个远程仓库通常只是一个裸仓库(bare repository)——即一个没有当前工作目录的仓库。 因为该仓库仅仅作为合作媒介,不需要从磁盘检查快照;存放的只有 Git 的资料。 简单的说,裸仓库就是你工程目录内的 .git 子目录内容,不包含其他资料。
$ git init --bare my_project.git
$ vim post-receive
#!/bin/sh
echo '------ update code ------'
cd /usr/local/webserver/nginx/hjranch
unset GIT_DIR
git pull origin main
# npm run build
# composer update
echo $(date) >> hook.log
echo '------ update completed ------'
$ chmod +x post-receive