Update on 06/08/2018
Tags: Github
- Author: Yunqiu Xu
git config --global user.name "Yunqiu Xu"
git config --global user.email "your email"
git config --list
exit
pwd
show your current positioncd /xyq/
switch to given positionls
list the files in this positiontouch fileName
create a empty file heremkdir xyq
create a folder heregit init
initialize this folder as a git repository
- This repository should be a "git repository" (using
git init
) git status
check the statusgit diff
check the differences
-
git add xyq.py
add your file to the cachegit add .
add all the files in this repository
-
git rm -cached
remove the files in the cache -
git commit -a -m 'your comment'
- If there is no '-a', you can not remove files
-
git log
check the commit history -
git reset --hard HEAD^
go back to previous versiongit reset --hard HEAD
current versiongit reset --hard HEAD^^
second last versiongit reset --hard HEAD^^^
third last version
-
A simple example:
git add xxx.py
git commit -m 'this it my submission'
git push origin master
ssh-keygen -t rsa
generate the SSH keycd ~/.ssh
cat id_rsa.pub
check the SSH key- Github -- Settings -- SSH and GPG keys -- New SSH Key -- Add your SSH key here
ssh -T git@github.com
check whether SSH is added successfully
git clone git@github.com:YunqiuXu/my_notes.git
- Then you can make some changes and push it back to Github
- Create an empty repository on Github, whose name is same to your local repository
git pull origin master
if the remote repository is not empty, you'd better to pull it to local firstgit push -u origin master
push the committed files to Github
git fetch origin master:temp
get remote branch and set its name as "temp"git diff temp
check the differences between "temp" and your local repositorygit merge
merge these branches- If there are changes that you want to keep, use
git commit
to commit them
- If there are changes that you want to keep, use
- Another method can be
git pull
, which is equal togit fetch + git merge
git branch
check current branchesgit branch xyq
create a new branchgit checkout xyq
switch to another branchgit branch -d xyq
delete branchgit merge
merge the branches