4

Git 备忘录

 3 years ago
source link: https://egoist.moe/git-memo
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Oct 07, 2015

Git 备忘录

Git 的一些常用操作备忘。

安装好 Git 之后,配置你的资料:

# 配置用户名
git config --global user.name "Your Real Name"
# 配置邮箱地址
git config --global user.email [email protected]

之后生成 SSH 密钥:

ssh-keygen -C '[email protected]' -t rsa

初始化一个项目

# 初始化 git 项目
git init
# 添加一个叫 origin 的源
# 使用 ssh 地址
git remote add origin [email protected]:username/reponame.git
# 使用 username/password 登录 https 地址
git remote add origin https://username@password:github.com/username/reponame.git

推送到服务器

# 记录所有新增和删除的文件
git add -A
# 更新理由
git commit -m "message"
# 推送到服务器端
git push origin master

更新到本地

# 源 + 分支名
git pull origin master

克隆项目

下载代码时有用:

# 克隆到以这个项目名命名的文件夹
git clone https://github.com/username/reponame.git
# 克隆到你自定义的文件夹
git clone https://github.com/username/reponame.git name

Keep Updating...


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK