Git: Difference between revisions
Line 12: | Line 12: | ||
=clone with token= | =clone with token= | ||
git clone https://git:<token>@ | git clone https://git:<token>@<git_server>/<repo>.git | ||
=which changes has occured= | =which changes has occured= |
Revision as of 10:52, 3 May 2024
setup git repository gitolite style
dnf install gitolite3
create new git repo
clone giolite-admin. Then edit conf/gitolite.conf and push it.
git clone gitolite3@halfface.se:gitolite-admin
Download a git repository
git clone git@www.halfface.se:project.git
clone git repository with other user and not trusted cert
env GIT_SSL_NO_VERIFY=true git clone https://user_name:P@ssW0rd@<git_server>/<git_repo>.git
clone with token
git clone https://git:<token>@<git_server>/<repo>.git
which changes has occured
git status
commit changes
git commit -a -m "updated ..."
change commit message
git commit --amend
push changes upsteam
git push git push origin master
list branches
List local and remote branches.
git branch -a
list remote branches.
git branch -r
Change branch
git checkout remotes/origin/code-18500
Change branch
git branch master
Delete Local Branch
git branch -d <branch_name> git branch -D <branch_name>
Delete Remote Branch
git push <remote_name> --delete <branch_name> # <remote_name> is most likely "origin"
git pull
sync up against git head
git pull
list files from specific branch, e.g. master
git ls-tree -r master --name-only
If you want to get a list of all files that ever existed
git log --pretty=format: --name-status | cut -f2- | sort -u
show where git repository is coming from/source
git remote show origin
git list tags
git tag -n
git diff
Difference between tags.
git diff tag1 tag2
Only show name of changed files.
git diff --name-only tag1 tag2
diff between master and branch
git diff master..772974_blabla_description_of_branch
diff between commit and what it was commited too.
git diff COMMIT~ COMMIT
List all sha1 codes for all objects
git rev-list --objects --all
git revert local changes
git reset --hard ; git clean -fd git reset --hard origin/master ; git clean -fd
git revert local changes
git add . git reset --hard
list tags containing commit
git tag --contains ${commit}
list dates in iso format
git log --date=iso $file
list log on line per entry
git log --oneline ansible.yml
look at content of file
git show 123131234242411fs1fds234fds14f1s4:/git/file.java
download specific version of file
git show af5bb0fe325300844195975a2f0c1f82979a7dd6:./git/search/path/file.txt > /temp/file.txt.af5bb0fe325300844195975a2f0c1f82979a7dd6
git gc
Compress and optimize git repository.
Return to master
git checkout master
checkout all modified files. Remove local changes
git checkout -- .
git reflog
Reference logs, or "reflogs" are a mechanism Git uses to record updates applied to tips of branches and other commit references. Reflog allows you to go back to commits even though they are not referenced by any branch or tag. After rewriting history, the reflog contains information about the old state of branches and allows you to go back to that state if necessary. Every time your branch tip is updated for any reason (by switching branches, pulling in new changes, rewriting history or simply by adding new commits), a new entry will be added to the reflog. In this section we will take a high level look at the git reflog command and explore some common uses.
git stash
git stash save # which enables including temporary commit message, which will help you identify changes, among with other options git stash list # which lists all previously stashed commits (yes, there can be more) that were not poped git stash pop # which redoes previously stashed changes and removes them from stashed list git stash apply # which redoes previously stashed changes, but keeps them on stashed lis git stash drop 0 # remove a stash entry.
rename branch
Rename current branch
git branch -m <newname>
Rename other branch
git branch -m <oldname> <newname>
Rename a local and remote branch
rename local branch.
git branch -m <newname>
Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
Reset the upstream branch for the new-name local branch. Switch to the branch and then:
git push origin -u new-name
view changes since creating branch
git diff @~..@
git checkout specific date
git checkout 'master@{1979-02-26 18:30:00}'
git push: fatal: The current branch "*" has no upstream branch.
To push the current branch and set the remote as upstream, use git push --set-upstream origin Problem_updating_certificate_automatically
Fix
git config --global push.default current
are there updates remotely
git fetch --dry-run
Update the remote-tracking branches
The above command copies all branches from the remote refs/heads/ namespace and stores them to the local refs/remotes/origin/ namespace, unless the branch.<name>.fetch option is used to specify a non-default refspec.
git fetch origin
Rebases current branch onto origin/master
git rebase origin/master
add file to commit
git add $file
remove file from commit
git reset $file
conflict management
Only list branches whose tips are reachable from the specified commit (HEAD if not specified). Implies --list.
git branch --merged [<commit>]
view commits from user
git log --author="Kjetil"
credentials
Save user and password
~/.git-credentials git config --global credential.helper store https://<username>:<password>@inter.net