Git

install:

$ sudo apt-get install git $ git config --global user.name "Your Name" $ git config --global user.email "email@example.com"

Creat repository

$ mkdir learngit $ cd learngit $ pwd $ git init //Initialized empty Git repository

Add files to repository

$ git add readme.txt $ git commit -m "//wrote a readme file"

modify

$ git status //Nowadays status $ git diff //Check difference $ git log --pretty=oneline//Check modify history $ git log --graph```//show as graph $ git reset --hard HEAD^ //back to last one ,one ^ by one / HEAD~100 $ git checkout -- file //Undo files $ git rm files //&commit

Remotely repository

$ ssh-keygen -t rsa -C "email@example.com"//Local pc $ git remote add origin git@github.comYournamegit.git//Only do in first time of a repository $ git push -u origin master//Only do in first time $ git push origin master

branche

$ git checkout -b dev//creat and switched,do somiting then commit like before $ git branch//check branche $ git checkout master//After finish dev,switch to master $ git merge dev or $ git merge --no-ff -m "merge with no-ff" dev $ git branch -d dev //deleted branche dev

When the work at hand is not completed, first save work site

$ git stash //then debug $ git stash pop //return $ git checkout -b dev origin/dev//creat remote branche

If git pull show “no tracking information”,it means local bransc doesn't match remote branch,please use:

$ git branch --set-upstream branch-name origin/branch-name

Tag

$ git tag v1.0 //First,switch to which branch you want to tag $ git tag//check $ git log --pretty=oneline --abbrev-commit```&```$ git tag v0.9 6224937 $ git tag -a v0.1 -m "version 0.1 released" 3628164 $ git push origin v1.0 $ git push origin --tags//all $ git tag -d $ git push origin :refs/tags///delete remote tag

linux

Tutorial One

  • The$ ls command ( lowercase L and lowercase S ) lists the contents of your current working directory.ls -a$ lists files that are normally hidden.
  • $ mkdir example(make directory)
  • $ cd (change directory)
  • (..) means the parent of the current directory
  • $ pwd (print working directory)

Tutorial Two

  • cp (copy):$ cp file1 file2
    Note: Don't forget the dot . at the end. Remember, in UNIX, the dot means the current directory.
  • $ mv file1 file2 moves (or renames) file1 to file2
  • $ rm (remove), rmdir (remove directory)
  • $ clear (clear screen) cat (concatenate)
  • $ lessThe command less writes the contents of a file onto the screen a page at a time.
  • The head command writes the first ten lines of a file to the screen. The tail command writes the last ten lines of a file to the screen.
  • $ wc (word count)

Tutorial Three

  • $ cat Then type a few words on the keyboard and press the [Return] key.
    Finally hold the [Ctrl]+[d] (written as ^D for short) to end the input.
  • Redirecting the Output $ command > filecreate file
posted on 2018-04-17 12:52  大燚哥  阅读(125)  评论(0)    收藏  举报