Skip to content

Latest commit

 

History

History
100 lines (72 loc) · 1.83 KB

File metadata and controls

100 lines (72 loc) · 1.83 KB

Git

Import a directory

cd existing_folder
git init
git remote add origin https://blah.git
git add .
git commit
git push -u origin master

Configuration

git config pack.windowMemory 10m
git config pack.packSizeLimit 20m
git config pack.threads 1

Reverting

  • Get a particular commit for a file: git checkout xxxx file. This is just to test a given commit.
  • To revert the last commit: git revert xxxxx. See here
  • Return from a detached HEAD state: git checkout master or git checkout -

Branches

Create the new branch:

git checkout master
git branch new-branch
git checkout new-branch

Then code, and commit on the new branch.

Finally, when you need to merge:

git checkout master
git merge new-branch

This merges everything locally. Solve merge conflicts. Finally:

git push origin master

To remove a remote branch: git push -d origin BRANCHNAME

To list remote branches:

git fetch
git branch -a

To switch to a branch: git checkout branchname

$ git config --global --list
credential.helper=store

Debug

$ git config --global --list
core.sshcommand=ssh -vvv

Gogs

Example of SSH config file ~/.ssh/config:

Host github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_xxxx

It is even possible to use different identities for different repositories on GitHub:

Host github.com/cryptax
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa

Host github.com/anotheridentity
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_other