git: system for version control
github: website to upload your directory

.md (markdown file):

## This is the header

Regular text

* bullet 1

[Link to Google](

fork->modify->pull request (does not sync with the upstream repo)

Init by clone

we can first init the repo on github, and then clone it to our local

open git bash:

cd \~/Desktop/
git clone *url*
cd *test-repo* (now we see the master branch, test-repo is directory
git remote -v
git remote add origin *url* (can skip the step if origin already exist)
touch (create a file on windows with non standard extension)
git status
git add (add one file)
git add . (add all files once)
git commit -m “edit readme and add” (remember to add the message)
git log
git push origin master

Init by fork

fork other people’s repo and there are some new commit in that repo:

git remote add upstream *url*
git fetch upstream
git merge upstream/master (new update is in the branch upstream/master)
git push origin master


mkdir test1
cd test1
git init
git remote add origin 
cp ../test.txt test.txt
git status
git add .
git commit -m “msg”
git push origin master **--此时出现error显示fail to push some refs to …
updates were rejected because the remote contains work that you do not
have locally**
git pull origin master
git push origin master --此时可以成功push

从远端拿东西最好用git fetch + git merge。如果直接使用git pull会覆盖本地有但是远端没有的文件。


git checkout -b newbranch    #新建branch,并且进入到new branch
git checkout master          #切换回到master
git merge newbranch          #这里是分支名字,将new branch内容合并到master branch
git branch -d newbranch      #当前分支已经没用了,记得删除,除非还需要用到
git branch                   #查看当前所在分支
git branch -A/--all          #查看所有分支

Roll Back

git log                                 #查看版本
git reset --hard             #回退到指定版本
git push origin HEAD --force            #清空这个commitid之后所有已经提交了的commit
git revert                   #剔除某次提交,其后的commit不受到影响

Author: csy99
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source csy99 !
shell shell
BasicVariableConvention: all caps for system variables, lower case for user defined variables. echo $BASH echo $BASH_VE
string string
字符串 考虑使用HashMap进行计数 掌握substring, indexOf, isLetterOrDigit等常见方法 考虑转换成char[] 比较一定要使用equals 找符合条件子串,考虑滑动窗口法,关键在于找到合法起始点 KMP