Git: Difference between revisions

From DWIKI
Tony (talk | contribs)
mNo edit summary
Tony (talk | contribs)
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Links=
=Links=
*[http://git-scm.com/ Homepage]
*[http://git-scm.com/ Homepage]
*[https://try.github.io Online git tutorial]


==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://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]
*http://gitref.org/basic/
*http://gitref.org/basic/
*http://git-scm.com/book/en
*http://git-scm.com/book/en
*https://www.atlassian.com/git/tutorials
*http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-
*[http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-
*[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]
===Git Tutorials===
*[https://try.github.io Online git tutorial]
*[https://www.atlassian.com/git/tutorials Git tutorial at atlassian]
*[https://docs.gitlab.com/tutorials/learn_git/ Git tutorial at Gitlab]
=Cheat sheet=
==Show changes in a file==
  git log --follow -p your.file
==Remove file from repository but not from filesystem==
git rm --cached filetokeep
and add it to .gitignore
==Create repository on server==
mkdir -p git/myproject
cd git/project
git init --bare
==Get git config==
git config --list
==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 =
==git pull==
===You are not currently on a branch.===


== error: src refspec master does not match any. ==
==Restore single file==
Move the file away and
git restore yourfile
 
==Error messages==
===warning: remote HEAD refers to nonexistent ref, unable to checkout===
You probably need to
git check master
of
git checkout main
 
===error: You have not concluded your merge (MERGE_HEAD exists).===
 
===error: unknown switch `b'===
Try '''--bare''' instead of '''-b'''
 
===git checkout errors===
====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!
ye well, screw you. you did something wrong!


 
 
=== Updates were rejected because the remote contains work that you do not have locally.===
??


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


This is not a joke!
This is not a joke!
For now check https://stackoverflow.com/questions/36086202/git-merge-is-not-possible-because-i-have-unmerged-files


== fatal: cannot do a partial commit during a merge. ==
== fatal: cannot do a partial commit during a merge. ==
Line 31: Line 107:
  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 ==


community qXcF52,:Kg
== error: Your local changes to the following files would be overwritten by merge:==
git stash
git pull
git stash pop


== list untracked files ==
== list untracked files ==
Line 43: Line 122:
File has to be added again
File has to be added again


 
 


== error: gpg failed to sign the data ==
== error: gpg failed to sign the data ==
Line 57: Line 136:
 git config --global user.signingkey  XXXXX
 git config --global user.signingkey  XXXXX


=Cheat sheet=


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


===fatal: detected dubious ownership in repository ===


==browse local repository==
git ls-tree --full-tree -r HEAD


==push as different user==
===Merge with strategy ort failed===
check .git/config and replace username
ORT stands for “Ostensibly Recursive Three-way”

Latest revision as of 07:37, 8 June 2026

Links

Documentation

Git Tutorials

Cheat sheet

Show changes in a file

 git log --follow -p your.file

Remove file from repository but not from filesystem

git rm --cached filetokeep

and add it to .gitignore

Create repository on server

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


Get git config

git config --list


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

Error messages

warning: remote HEAD refers to nonexistent ref, unable to checkout

You probably need to

git check master

of

git checkout main

error: You have not concluded your merge (MERGE_HEAD exists).

error: unknown switch `b'

Try --bare instead of -b

git checkout errors

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!


Updates were rejected because the remote contains work that you do not have locally.

??

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

This is not a joke!

For now check https://stackoverflow.com/questions/36086202/git-merge-is-not-possible-because-i-have-unmerged-files

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:

git stash
git pull
git stash pop

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

Merge with strategy ort failed

ORT stands for “Ostensibly Recursive Three-way”