Git: Difference between revisions

From DWIKI
 
(11 intermediate revisions by the same user not shown)
Line 5: Line 5:


==Documentation==
==Documentation==
*[https://git-scm.com/book/en/v1/Getting-Started-First-Time-Git-Setup Getting Started]
*[https://git-scm.com/book/en/v1/Getting-Started-First-Time-Git-Setup Getting Started in the Pro Git Book]
*[https://www.inmotionhosting.com/support/website/git/setting-up-your-remote-repository-with-git/ Setting Up Your Remote Repository With Git]
*[https://www.inmotionhosting.com/support/website/git/setting-up-your-remote-repository-with-git/ Setting Up Your Remote Repository With Git]
*[https://git-scm.com/book/uz/v2/Customizing-Git-Git-Attributes Dealing with binary files]
*[https://git-scm.com/book/uz/v2/Customizing-Git-Git-Attributes Dealing with binary files]
Line 14: Line 14:
*[https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository Recording Changes to the Repository]
*[https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository Recording Changes to the Repository]
*[https://raymii.org/s/tutorials/Shared_Git_repository_via_ssh_for_multiple_users.html Shared Git repository over ssh for multiple users]
*[https://raymii.org/s/tutorials/Shared_Git_repository_via_ssh_for_multiple_users.html Shared Git repository over ssh for multiple users]
=Cheat sheet=
==Create repository on server==
mkdir -p git/myproject
cd git/project
git init --bare
==browse local repository==
git ls-tree --full-tree -r HEAD
==push as different user==
check .git/config and replace username
==Switch to particular branch==
git branch -a
git checkout remote/releases/6.4
and to get back
git checkout master
or was it
git checkout
==Git move==
  git mv file.txt newfile.txt


= FAQ =
= FAQ =
==Automatic merge failed; fix conflicts and then commit the result.==Try
==git pull==
===You are not currently on a branch.===
 
 
==Restore single file==
Move the file away and
git restore yourfile
 
 
==git checkout==
===error: pathspec 'master' did not match any file(s) known to git===
then you get that from
git checkout master
try
git checkout -
 
 
 
==Automatic merge failed; fix conflicts and then commit the result.==
 
Try
   git mergetool
   git mergetool


Line 33: Line 80:
  git commit -i
  git commit -i


== error: Pulling is not possible because you have unmerged files ==
== error: Pull is not possible because you have unmerged files ==


== error: Your local changes to the following files would be overwritten by merge:==
== error: Your local changes to the following files would be overwritten by merge:==
Line 63: Line 110:
 git config --global user.signingkey  XXXXX
 git config --global user.signingkey  XXXXX


==You have divergent branches and need to specify how to reconcile them.==
 
==Git error messages==
===You have divergent branches and need to specify how to reconcile them.===
First try:
First try:
  git merge
  git merge
=Cheat sheet=
==Create repository on server==
mkdir -p git/myproject
cd git/project
git init --bare




==browse local repository==
===fatal: detected dubious ownership in repository ===
git ls-tree --full-tree -r HEAD
 
==push as different user==
check .git/config and replace username

Latest revision as of 14:55, 6 December 2024

Links

Documentation

Cheat sheet

Create repository on server

mkdir -p git/myproject
cd git/project
git init --bare


browse local repository

git ls-tree --full-tree -r HEAD

push as different user

check .git/config and replace username


Switch to particular branch

git branch -a
git checkout remote/releases/6.4

and to get back

git checkout master

or was it

git checkout


Git move

 git mv file.txt newfile.txt

FAQ

git pull

You are not currently on a branch.

Restore single file

Move the file away and

git restore yourfile


git checkout

error: pathspec 'master' did not match any file(s) known to git

then you get that from

git checkout master

try

git checkout -


Automatic merge failed; fix conflicts and then commit the result.

Try

 git mergetool

error: src refspec master does not match any.

ye well, screw you. you did something wrong!

 

error: Merging is not possible because you have unmerged files.

This is not a joke!

fatal: cannot do a partial commit during a merge.

git commit -i

error: Pull is not possible because you have unmerged files

error: Your local changes to the following files would be overwritten by merge:

move the file away and try again?



list untracked files

git status

Changes not staged for commit:

File has to be added again

 

error: gpg failed to sign the data

try

GIT_TRACE=1 commit ...

and run the command it suggests

but your problably forgot to

 git config --global user.signingkey  XXXXX


Git error messages

You have divergent branches and need to specify how to reconcile them.

First try:

git merge


fatal: detected dubious ownership in repository