dev:git

git

see also: "Oh shit, git!"

reset changes of specific file git checkout – filename
undo all changes since last commit git reset –hard
merge multiple commits
(tutorial)
git rebase -i
show remote repositories git remote
git config user.name "John Doe"
git config user.email "john@doe.org"
# I want to make sure my master is in sync with the upstream master
git checkout -b merge-patches master
# first pull request
git pull --no-ff https://github.com/user1/repo.git master
# second pull request
git pull --no-ff https://github.com/user2/repo.git branch1
git remote add upstream path/to/repository.git
# get all refs and objects so your git knows what it can do
git fetch --all

You can merge foreign branches:

git merge upstream/master
.git/config
[remote "origin"]
    # add this line
    fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

then execute:

# get refs
git fetch --all
 
# merge pull request with ID 999
git checkout pr/999

(Source)

# change to branch to be added
git checkout master
# push it to the repo
git push -u origin master

Error: [remote rejected] master → master (branch is currently checked out)

# push to new branch on remote
git push origin master:refs/heads/upload
# on remote machine
git merge upload
git branch -d upload

Alternative: allow update of local branch

git config --local receive.denyCurrentBranch updateInstead

(Quelle)

echo "*" >> ~/.gitignore
git add -f .gitignore
dotfile hinzufügen git add -f .dotfile

on the target peer

echo "*" >> ~/.gitignore
initialise git init
add remote git remote add hostname:~
fetch files git fetch –all
replace existing git reset –hard origin/master

(Source)

Do a "git diff" on any file. What do you see?

The permissions have all changed!

git config core.filemode false

The whole file changed with weird ^ characters!

These are the line endings. Automatically adjust it to CRLF line endings with:

git config --global core.autocrlf true
  • meldGUI Merge
  • git-extras – tools which make working with git easier
  • BFG Repo-Cleaner – Removes large or troublesome blobs and files you don't want in your git history.
  • Last modified: 2020-05-21 07:42