Git

From no name for this wiki
Jump to: navigation, search

switch branch

git checkout -b <branch>

Mit der b Option wird ein neuer Branch kreiert.

branch löschen

git checkout -d <branch>

fetch und pull

git fetch origin

git fetch really only downloads new data from a remote repository - but it doesn't integrate any of this new data into your working files.

git pull origin master

git pull, in contrast, is used with a different goal in mind: to update your current HEAD branch with the latest changes from the remote server.

set remote url

git remote set-url origin https://github.com/username/repo

stash

git stash
git stash list

Speichert alle Änderungen und macht ein undo changes. Diese können später wieder aktiviert werden:

git stash pop

merge

git merge <branch_to_merge_into_current>
git status

Merge auflösen.

<<<<<<< HEAD
this is some content to mess with
content to append
=======
totally different content to merge later
>>>>>>> new_branch_to_merge_later
final text
git add conficted.txt
git commit -m "blabal" 


rebase

git rebase

Git remote URL anzeigen

git remote show origin
git config --get remote.origin.url

Force add von packages

git add -f ./*

undo all changes

git reset --hard # removes staged and working directory changes
git clean -f -d # remove untracked
git clean -f -x -d # CAUTION: as above but removes ignored files like config.
git clean -fxd :/ # CAUTION: as above, but cleans untracked and ignored files through the entire repo (without :/, the operation affects only the current directory)

log

git log --stat 
git log --since=2.weeks

git in anderes repository zügeln

git remote set-url origin https://myusername@blabla/blibli/blabla.git
git fetch 
git push

letzten commit rückgängig machen

git reset HEAD~

This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they'll appear as "Changes not staged for commit" in git status, so you'll need to add them again before committing).

If the code is already pushed to your server and you have permissions to overwrite history (rebase) then:

git push origin master --force