您的位置:首页 > 编程语言

Github基本操作【学习笔记】

2014-02-26 17:14 218 查看
Set Up Git

配置全局用户名

git config --global user.name "Your Name Here"

配置全局邮箱

git config --global user.email "your_email@example.com"

配置全局邮箱

Create A Repo

More about repositories

Click New Repository.

Click "New Repository

Fill out the information on this page. When you're done, click "Create Repository."

Fill in the info

Congratulations! You have successfully created your first repository!

远程仓库建立后,在本地建立项目

mkdir ~/Hello-World

# Creates a directory for your project called "Hello-World" in your user directory

cd ~/Hello-World

# Changes the current working directory to your newly created directory

git init

# Sets up the necessary Git files

# Initialized empty Git repository in /Users/you/Hello-World/.git/

touch README

# Creates a file called "README" in your Hello-World directory

提交指定的文件

git add README

# Stages your README file, adding it to the list of files to be committed

git commit -m 'first commit'

# Commits your files, adding the message "first commit"

将本地动作提交到远程仓库

git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repository

git push origin master

# Sends your commits in the "master" branch to GitHub

发现无法提交,解决办法直接暴力上传

To https://github.com/kelespring/test.git
! [rejected] master -> master (fetch first)

error: failed to push some refs to 'https://github.com/kelespring/test.git'

hint: Updates were rejected because the remote contains work that you do

hint: not have locally. This is usually caused by another repository pushing

hint: to the same ref. You may want to first integrate the remote changes

hint: (e.g., 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

git push -f

讲远程仓库下载到本地

git clone https://github.com/username/Spoon-Knife.git
先写到这里
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: