Skip to content

nokobear/git-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-test

How to use git effectively. (This is my memo.)

git frontends

  • browser (github)
  • git (local)
  • tig (local)

git commands

clone (remote -> local)

git clone https://github.com/nokobear/git-test

view

git log
git status

action

git add .
git commit -m "message"
git tag 0.1.0 105e2e57fff64791b5899f569b30272ae063f4ef

push (local -> remote)

git push origin master

branch (optional)

git branch                            # view list
git branch dev1                       # create new branch "dev1"
git checkout dev1                     # switch to branch "dev1"
git checkout master; git merge dev1   # merge (master = master + dev1)

git configuration

git config --global user.name   nokobear
git config --global user.email  "42159927+nokobear@users.noreply.github.com"
git config --global color.ui    auto
git config --global alias.co    checkout
git config --global core.editor /usr/bin/vim

or edit ~/.gitconfig directly
~/.gitconfig

[user]
	name = nokobear
	email = 42159927+nokobear@users.noreply.github.com
[color]
	ui = auto
[alias]
	co = checkout
[core]
	editor = /usr/bin/vim

push without password

4 methods to do it.

  1. use ssh
  2. use https and cached password
  3. use https and .netrc (bad method in the point of security.)
  4. use https and .netrc.gpg

1-3. omit
see: authenticating-with-github-from-git

4. use https and .netrc.gpg

create ~/.netrc

touch ~/.netrc
chmod 600 ~/.netrc
vim ~/.netrc

~/.netrc

machine github.com
  login nokobear
  password xxxxxxxxxxxx
  protocol https

machine gist.github.com
  login  nokobear
  password xxxxxxxxxxx
  protocol https

push test.

cd git-test
git push origin master

gpg encrypt.

gpg --gen-key
# ( keytype:RSA and RSA, bitlength:2048, limit:0day(unlimited),
#   name:nokobear, email:email_address, comment:
#   password: )
gpg -e -r email_address ~/.netrc
rm ~/.netrc

setup git-credential-netrc

# (download to ~/bin)
curl -o ~/bin/git-credential-netrc https://raw.githubusercontent.com/git/git/master/contrib/credential/netrc/git-credential-netrc
chmod 755 ~/bin/git-credential-netrc
git config --global credential.helper "netrc -f ~/.netrc.gpg -v"

modify ~/.netrc (optional)

# (decrypt)
gpg -d ~/.netrc.gpg > ~/.netrc
vim ~/.netrc
# (encrypt)
gpg -e -r email_address ~/.netrc
rm ~/.netrc

tig

tig         # view-main(m)
tig status  # view-status(s)

view-main

tig-view-main

jk: select
s:  view-status
q:  quit (or return)
h:  help

view-status

tig-view-stauts()

jk: select
u:  git add (or undo git add)
C:  git commit
q:  quit (or return)

u -> git add tig-view-status(added)

C -> commit tig-commit

vim
:wq  commit
:q!  cancel

test show image

hello

About

How to use git effectively. (This is my memo.)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published