基本的git/linux/g++/ 等指令

0 引言

本文将常用的指令记录下来,以备查询。

1 git

Command
Meaning
Reference Linking

git status

view all files‘ state, tracked or untracked, commited or un commited

 

git status -uno

view files‘ state, not including untracked files

https://blog.csdn.net/anlian523/article/details/98041383

git checkout -b  [branchname]

create a branch named [branchname] and switch to it

equals to $ git branch [branchname] && $ git checkout [branchname]

 

git branch

view local branches

$ git branch -a # view all of the branches, including local and remote branches

$ git branch -r # view remote branches

 

git checkout 

 

 

git remote 

view the remote server name

 

git fetch origin

to update remote branch information

 

git remote show origin

view all the corresponding relations between local and remote branches

 

git clone ssh://git@git-brion-us.asml.com:7999/brion_rnd_sjb/tachyon_prd.git

real link of our repository

 

git reset

  • git reset –-hard: to discard all local changes

 

git checkout  — files

to discard unadded changes in a file

 

*** git branch -d feature/dev

delete local branches in Git

 

*** git push origin –delete feature/dev

delete remote branches in Git

 

git clone -b LMC/kwang10/dev1 –single-branch url

clone a specific branch from remote repository

 

git pull origin tachyon-RDI-10

merge the group  code with local code

 

git clone -b LMC/testauthorname –single-branch ssh://git@git-brion-us.asml.com:7999/brion_rnd_sjb/tachyon_prd.git

 LMC/testauthorname

 

merge from hotfix branch back to develop

How to merge from hotfix branch back to develop

 

git fetch

git checkout origin/tachyon-RDI-10 — file

  • usage: git pull a single file from remote repository

  • origin/tachyon-RDI-10 can be replaced by any branch name

  • file is the relative path of a specific file

 

git diff filename

watch the difference between version_latest and version_old of “filename”

 

git reset –hard

–hard

Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.

 

git log –after=”2021-01-05 00:59″ –before=”2021-01-05 20:37″ author=”testauthorname”

specific time slots for specfic author.

 

git cherry-pick <commitHash>

quick merge commit to branch 10 if merge conflict

 

2 linux

Command

Meaning

reference linking

sudo chmod -R 777 Document/

change the visit permission of a file

 

touch

create a new file

 

mkdir

create a new file folder (or a new directory)

 

reset

initialize the console and clear the window

 

clear

clear the content shown on the screen

 

#

annotation

 

ls

list all file in current directory(files named with .xxx not included )

 

ls -l

list all files and the detailed properties

 

ls -a

list all file in current directory(files named with .xxx also included )

 

whereis [filename]

list the directory of files named [filename]

 

rm [filename]

remove a file named [filename], need confirm

 

rm -f [filename]

remove a file named [filename], don‘t need confirm, ‘-f‘ means force

 

rm -r -f [folder]

remove a folder named [folder], don‘t need confirm

 

-r

a parameter used when dealing with a folder

 

cp [options] source dest

copy and paste the content of a file/directory from source to dest

 

cat file

print the file content on the screen

 

find /home -name “*.txt”

find the files ended with “.txt” in directory “/home”

 

find /home -iname “*.txt”

find the file ended with “.txt” in directory “/home”, and set case insensetive

 

grep -rnw “what you are search for” /path

search for content in your file in a specific path

 

grep –include=\test*.txt -irnw ‘./‘ -e “touch”

search for content in files named after a particular pattern

  • ‘-i‘: ignore case

  • ‘-r‘:recursive

  • ‘-n‘:show the line number where my content appears

  • ‘-w‘:match the whole word

stackoverflow_how_to_search_content

egrep –include=\* -irn -e “def1\.size\(\) = [0-9]+”

grep with regular expression

 

tree -d directory

show only folders

 

du -h

check how much storage the current directory has used.

 

wc 

  • wc -l job_message.txt: count how many lines in this file

  • wc -w job_message.txt: count how many words in this file

 

killall -u kwang10

kill all processes of user “kwang10”

 

awk

get column

 

diff file1 file2

  • usage: compare the content of 2 files

  • file1: benchmark

  • file2: modified from file1

    • 4c4: changed the 4th row of file1
    • 4, 6d3: deleted from 4 to 6 row in file1, at the place of row 3 in file2
    • < a: delete a
    • > b: add b
    • —: separate modified place of file1 and file2

https://www.cnblogs.com/sevck/p/5036976.html

ssh -X dn121201

transfer to dn server, “-X” means gui should be supported.(when open tachyon-flex gui)

 

awk

求和:awk ‘{sum += $1};END {print sum}‘  test.txt

 

 

     
     
     

3 vim

Command
Meaning
Reference Linking

i

insert at the curser

 

a

add after curser

 

A

add at the end of this row

 

x

remove character at curser

 

nx

remove n character at curser

 

dd

remove or cut the whole row

 

ndd

remove or cut n row begin at curser

 

/text

find the first “text” pattern in current file after curser

 

?text

find the first “text” pattern in current file before curser

 

s/old/new

substitute “old” pattern use “new”

 

yy

copy current row to cache

 

nyy

copy n rows to cache from curser

 

p

paste from cache

 

u

cancel the last modification

 

:set nu

display number of rows

 

:set nonu

remove number of rows

 

:q

quit from vi

 

:w

save modifications

 

:q!

quit without save of modifications

 

:w!

save it forcely

 

:wq!

save and quit forcely

 

:vsplit [filename]

vertically split the screen and open a new file

 

:u

undo 

 

:nu

undo for n times

 

:row_begin, row_end >

to tab from row_begin to row_end

 

:row_begin, row_end <

to reverse tab from row_gebin to row_end

 

:/search_word  + n /N

press n to search forward, N to search backward

 

:/foo\c

search “foo” and set case insensetive

 

:/foo\C

search “foo” and set case insensetive

 

:%s/Template\C/int/g

search all “Template” and replace them with “int”

 

:3,4s/Template/int

search “Template” in 3 and 4 row and replace them with “int”

 

ps -ef |grep kwang10

 

 

killall -u kwang10

kill all for kwang10

 

automatically edit format

  • set in .vimrcshift + g + line_begin: move to line head

    • filetype plugin indent on
    • set cindent shiftwidth=4
  • v: transform to visual mode

  • shift + g + line_end: move line end

  • =

 

4 g++

Command
Meaning Reference Linking

g++ -E test.cpp -o test.i

preprocessing, operated by the preprocessor, to produce a file ended with “.i”

 

g++ -S test.i -o test.s

compilation, to compile a “.i” ended file into a “.s” ended file 

 

g++ -c test.s -o test.o

assembly, operated by the compiler, to produce a binary file

 

g++ test.o -o test.out

linking, linker will link all “.o” files to produce a executable file

 

g++ main.cpp -o main

compiling and linking a single main.cpp

 

g++ main.cpp include/add.cpp -o main

compliling many different files together, with .h and .cpp files

 

g++ src/.*cpp -c -Iinclude/

compile all ,cpp files in src into .o files

 

ar rcs libMyAdd.a *.o

to package all .o files into a .a static linking libraries.
“lib + name + .a” is the standard naming rules for static linking libraries.

 

g++ main.cpp lib/libMyAdd.a -o sum -Iinclude/
g++ main.cpp -Iinclude/ -L./lib -lMyAdd

to compile main.cpp with static linking libraries.

 

g++ -fpic -c src/*.cpp

to create binary code location independently

 

g++ -shared -o libMyAdd.so *.o -Iinclude

to package all .o files into a .so shared linking libraries.

 

g++ main.cpp lib/libMyAdd.so -o app -Iinclude
g++ main.cpp -Iinclude/ -L./lib -lMyAdd -o app

to compile main.cpp with shared linking libraries
error: cannot open shared object file: No such file or directory
solution 1: add .so path into LD_LIBARY_PATH
$ export LD_LIBRARY_PATH=./lib // temporary effective
solution 2: add it into .bashrc
$ export LD_LIBRARY_PATH=/home/kwang10/test/lib
$ source ~/.bashrc

 

ldd app

check if all the files which app depends are normal

 

g++ -* 

  • -o: to name the executable file 

  • -D: to define Macro definition

  • -I: to specify the path to the header files

  • -g: added when debugging using gdc

  • -O: to determine compiler optimization accoring to number, from 1 to 3

  • -Wall: to output warning information

  • -std=C++11

 

 

 

 

 

 

 

5 gdb

start

start to execute, only execute one step

r

Start running program until a breakpoint or end of program

n(next)

next step

s(step)

runs the next line of the program

s N

runs the next line of the program

difference between next and step

n will not enter a function, but s can enter a function

c(continue)

continue to execute until meet a break point

f

runs until the current function is finished

l file_name: 

  • + row number

  • + function name 

  • press enter to show next lines

b(break)

  • b n : set a break point at the n line of current file

  • b n if condition == true : set if true

  • b file.c: N : set at the N line of file “”

  • b fun: set at the begining of function “fun”

i b(information break)

to show break point information

p variable name

view value of variable

ptype

view type of variable

 

基本的git/linux/g++/ 等指令

原文地址:https://www.cnblogs.com/ghjnwk/p/14409242.html

系统相关
我还没有学会写个人说明!
下一篇

折叠屏iPhone正在路上曝LG将为苹果开发可折叠显示屏

你也可能喜欢

评论已经被关闭。

插入图片