wiki:GitSurvival

Reading

Deal with "Your local changes...would be overwritten

  git reset -- hard       # this kills all local changes, careful!
  git pull

Switch to (remote) branch

  $ git checkout -b <branch> --track <remote>/<branch>

Update submodule to latest

https://github.com/tj/git-extras/pull/80

  cd submodule_name
  git checkout master && git pull
  cd ..
  git add submodule_name
  git commit -m "updating submodule to latest"

See what branch we are on

  $ git branch -a

View graph of branches

git log --graph --oneline --decorate
git log --graph --oneline --decorate --all

Undo changes to one file

See https://stackoverflow.com/questions/692246/undo-working-copy-modifications-of-one-file-in-git

  $ git checkout -- file

Avoiding to always type password

Normal editing

  $ git clone ssh://git@gitlab.cern.ch:7999/atlas-hllhc-muon-mdt-trigger-doc/Proto0_Blade.git
  $ cd Proto0_Blade
  $ (edit files)
  $ git commit -a     # commit changes (not new files) to local
  $ git push --all    # push changes back to master on remote

To check out a specific revision, figure out the SHA1 code (long hex string), then:

  $ git fetch origin <SHA1>
  $ git reset --hard <SHA1>
Last modified 7 weeks ago Last modified on Oct 14, 2020, 12:27:06 PM