基本的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 |
|
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 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 |
|
|
git fetch git checkout origin/tachyon-RDI-10 -- 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 |
|
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
|
|
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 |
|
|
killall -u kwang10 |
kill all processes of user "kwang10" |
|
awk |
get column |
|
diff file1 file2 |
|
|
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 |
|
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. |
|
g++ main.cpp lib/libMyAdd.a -o sum -Iinclude/ |
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 |
to compile main.cpp with shared linking libraries |
|
ldd app |
check if all the files which app depends are normal |
|
g++ -* |
|
|
|
|
|
|
|
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: |
|
b(break) |
|
i b(information break) |
to show break point information |
p variable name |
view value of variable |
ptype |
view type of variable |