Maschette / git_bash

Cheat sheet and tricks for gitbash
2 stars 0 forks source link

What do we need on a cheatsheet #1

Open Maschette opened 4 years ago

kimnewzealand commented 4 years ago

Basic commands

I am actually going back to basics with the command line and working through this tutorial. https://swcarpentry.github.io/shell-novice

I don't think I have the right foundations and may have gaps in this basic knowledge. Since the command line or bash isn't as visual as a GUI tool, maybe we need to be comfortable in navigating these to have the understanding and confidence to use the Git workflows?

softloud commented 4 years ago

I am inspired, @kimnewzealand, I'll take a look at that tutorial, too.

In addition, for ideas, I'll list some of my dream questions/problems I wish I had a ready go-to sheet for. Maybe too high level, but these are the kinds of finicky things that are eating my time:

Maschette commented 4 years ago

At least on that last point I have always considered branch vs fork as "i own this repo" vs "I don't own this repo"

softloud commented 4 years ago

We're doing feature branch dev from the same repo, no forks, and it's quite a challenge!

kimnewzealand commented 4 years ago

Basic commands

I am actually going back to basics with the command line and working through this tutorial. https://swcarpentry.github.io/shell-novice

I don't think I have the right foundations and may have gaps in this basic knowledge. Since the command line or bash isn't as visual as a GUI tool, maybe we need to be comfortable in navigating these to have the understanding and confidence to use the Git workflows?

The file system is responsible for managing information on the disk.

Information is stored in files, which are stored in directories (folders).

Directories can also store other directories, which forms a directory tree.

cd path changes the current working directory.

ls path prints a listing of a specific file or directory; ls on its own lists the current working directory.

pwd prints the user’s current working directory.

/ on its own is the root directory of the whole file system.

A relative path specifies a location starting from the current location.

An absolute path specifies a location from the root of the file system.

Directory names in a path are separated with / on Unix, but \ on Windows.

.. means ‘the directory above the current one’; . on its own means ‘the current directory’.

mkdir path creates a new directory.

cp old new copies a file.

mv old new moves (renames) a file or directory.

rm path removes (deletes) a file.

(star) matches zero or more characters in a filename, so .txt matches all files ending in .txt.

? matches any single character in a filename, so ?.txt matches a.txt but not any.txt.

Use of the Control key may be described in many ways, including Ctrl-X, Control-X, and ^X.

The shell does not have a trash bin: once something is deleted, it’s really gone.

Most files’ names are something.extension. The extension isn’t required, and doesn’t guarantee anything, but is normally used to indicate the type of data in the file.

Depending on the type of work you do, you may need a more powerful text editor than Nano.

cat displays the contents of its inputs.

head displays the first 10 lines of its input.

tail displays the last 10 lines of its input.

sort sorts its inputs.

wc counts lines, words, and characters in its inputs.

command > file redirects a command’s output to a file (overwriting any existing content).

command >> file appends a command’s output to a file.

first |second is a pipeline: the output of the first command is used as the input to the second.

The best way to use the shell is to use pipes to combine simple single-purpose programs (filters).

Licensed under CC-BY 4.0 2018–2020 by The Carpentries Licensed under CC-BY 4.0 2016–2018 by Software Carpentry Foundation

Other basic commands I discovered:

rmdir remove directory env look at your environment echo print curl transfer data

Other basic commands with flags/ options/parameters (flags start with -)

recursive flag -r for example use the rm command with the recursive option, -r rm -r directory to remove a a directory and all its contents, including any subdirectories and files,

long flag -l for example print a more detailed listing of a directory ls -l

help flag --help after the command for example ls --help

softloud commented 4 years ago

I love love love these notes, @kimnewzealand. I so need/want to up my bash game. Are we wanting a bash cheatsheet, a git command line cheatsheet, or both? I'm unsure of our objective here.

Because just on the bash side, I have other specific things I'm grappling with.

sed -i "s/oldtext/newtext/g" replaces oldtext with new text for all files in the directory you are in. I'm using this a lot for working on now. I'd love to be able to pipe with it. This resource has been somewhat helpful, but it's overload for my abilities (hence the working through this swj tutorial) and I end up on stackexchange.

Maschette commented 4 years ago

I was thinking a git command line cheatsheet but there is no reason we cant make one for each

kimnewzealand commented 4 years ago

I love love love these notes, @kimnewzealand. I so need/want to up my bash game. Are we wanting a bash cheatsheet, a git command line cheatsheet, or both? I'm unsure of our objective here.

Because just on the bash side, I have other specific things I'm grappling with.

sed -i "s/oldtext/newtext/g" replaces oldtext with new text for all files in the directory you are in. I'm using this a lot for working on now. I'd love to be able to pipe with it. This resource has been somewhat helpful, but it's overload for my abilities (hence the working through this swj tutorial) and I end up on stackexchange.

yes I was feeling great cruising through it until I got to the pipes and loops. I think I'm happy enough for now knowing that is possible in bash..........

Regarding what and how many to create I am not fixed on this and open to ideas

kimnewzealand commented 4 years ago

Git command line cheatsheet resources/ suggestions

https://github.github.com/training-kit/downloads/github-git-cheat-sheet/