Difference between revisions of "Git"

From Torben's Wiki
m
m (Notes of 2020)
 
Line 38: Line 38:
 
  # Finally, force update to our repository:
 
  # Finally, force update to our repository:
 
  git push -f origin master
 
  git push -f origin master
 +
 +
====Re-apply .gitignore====
 +
from [https://stackoverflow.com/posts/52621453/timeline]
 +
# Commit all your pending changes
 +
...
 +
# Remove everything from the git index in order to refresh your git repository:
 +
git rm -r --cached .
 +
# Add everything back into the repo:
 +
git add .
 +
# Commit these changes:
 +
git commit -m ".gitignore issue fixed"
  
 
====Git Settings====
 
====Git Settings====

Latest revision as of 13:24, 19 May 2020


Notes of 2020

very nice tutorial: git - Der einfache Einstieg

clone a repository

git clone git@github.com:entorb/rememberthemilk.git

perform a commit

git add .
git commit -m "my commit message"
git push

revert a commit

get hash of commit
git log --oneline
git revert <commit hash>
# git push

revert local git to remote repository from [1]

git reset --hard HEAD
git clean -f -d
git pull

delete complete commits history
from [2] -> First Method

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH
# Add all the files:
git add -A
# Commit the changes:
git commit -am "Initial commit"
# Delete the old branch:
git branch -D master
# Rename the temporary branch to master:
git branch -m master
# Finally, force update to our repository:
git push -f origin master

Re-apply .gitignore

from [3]

# Commit all your pending changes
...
# Remove everything from the git index in order to refresh your git repository:
git rm -r --cached .
# Add everything back into the repo:
git add .
# Commit these changes:
git commit -m ".gitignore issue fixed"

Git Settings

colorful output

git config color.ui true

log: one line per commit

git config format.pretty oneline

Old notes

[4] [5]

git init # create an empty git repository in the current folder
# set some settings
git config --global user.name "Torben Menke"
git config --global user.email "torben.menke@XXX.de"
git config --global color.ui auto
git config -l # shows configuration

git add somefile.txt # one file
git add somefolder # one folder
git add . # all

git commit 
git commit -a -m "message" # commit all, message="message"

git pull ssh://tmenke@[IP]/[PATH] master
# edit
# commit
git push ssh://tmenke@[IP]/[PATH] master

git log
git log --pretty=oneline --abbrev-commit