pwd
mkdir myTestRepo
cd myTestRepo
.git init
ls -a
: presence of .git
vi hello.sh
- Open a new file in vi (or vim) named hello.sh
.i
- Enter “Insert” mode. #!/bin/bash
echo "Hello world"
Esc
- Leave “Insert” mode.:wq
, Enter
- Issue the command “Write, then quit.”chmod +x hello.sh
./hello.sh
git status
: “untracked”git add hello.sh
Other wildcards:
*.txt
- nonrecursive\*.txt
- subdir recursivegit add -A
- match working directory.gitignore
git status
git commit -m "Initial commit."
vi hello.sh
- Open the editor.j
- We’re in command mode, so this doesn’t insert a character, but instead moves the cursor down a line.llllllllllllllllll
- Move the cursor between d
and "
. If you overshoot, you can press h
as many times as you need to go back the other way.i
- Enter insert mode., I can use git!
- Enter some text.Esc
, :wq
, Enter
- Return to command mode, save, and quit, as before../hello.sh
git status
git diff --word-diff hello.sh
git commit -a -m "Add qualifications."
.git log
git diff --word-diff HEAD~ HEAD hello.sh
HEAD~~~
: “the parent of the parent of the parent of HEAD
”HEAD~4
HEAD@{yesterday}
1c002d
as shorthand for 1c002dd4b536e7479fe34593e72e6c6c1819e53b
DANGER ALERT: If you have uncommitted changes in your working directory, the following commands can destroy them, leading to lost work. Make sure you git status
to make sure your working directory is clean!
git checkout HEAD~
'detached HEAD' state
cat hello.sh
git checkout master
.git revert HEAD
: add a new commit “reversing” the last oneMake a new bare repo on GitHub
myTestRepo
git remote add origin https://github.com/Username/myTestRepo.git
git push origin master
git fetch
git pull
git clone
This page was automagically generated by GitHub Pages from a repo that you can find here. You can see the license for this page below.
git checkout -b <branchname>
git reflog
git checkout <branchname>
We’ll do this live!
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.