Intro to Git - raisercostin/software-wiki GitHub Wiki
For install go to Install section.
Is best to have the following configuration
git config --global credential.helper wincred
# Don't autocorrect EndOfLines between windows/linux/osx
git config --global core.autocrlf false
git config --global pull.rebase true
# Use iso date format YYYY-MM-DD HH:mm:ss +Z: like in 2006-07-03 17:18:43 +0200
git config --global log.date iso8601
git config --global credential.helper="C:/Users/CostinGrigore/scoop/apps/git/current/mingw64/bin/git-credential-manager.exe"
git config --global user.name "Costin Grigore"
git config --global user.email "[email protected]"
echo windows longpaths
git config --global core.longpaths true
--
<!--EndFragment-->
</body>
</html>
git config --global user.email [email protected]
git config --global user.name yourUsername
# Configure git to use project wide, shared, local hooks like pre-commit . Add to `.githooks\` folder any hooks from `.git\hooks\*.sample` and remove sample
#git config core.hooksPath .githooks\
- For iso date see https://stackoverflow.com/questions/19742345/what-is-the-format-for-date-parameter-of-git-commit/19742762#comment82502879_19742762
- used: When you need to run a command between all commits (all branches) to change something in the history like delete, rename, format, change authors, dates, folders, etc. The filter branch will create a parallel history that you can use.
- https://manishearth.github.io/blog/2017/03/05/understanding-git-filter-branch/
Working with rebase
git checkout -b dev/costin1
git checkout -b dev/costin2
tortoisegitproc /command:revisiongraph
git checkout -b dev/costin3
git checkout -b dev/costin3 master
git checkout -b dev/costin4 master
git checkout master
git checkout master --force
git checkout -b dev/costin4
git commit -am "fix"
git push --force
git push --set-upstream origin dev/costin4
git push --set-upstream origin dev/costin3
git fetch -v --progress --prune "origin"
In git a user can have read or read/write access. Usually there are no permission control over parts of the folders from git. There is a form of permission control on branches. The patterns are:
- Read Only
- Read/Write
- Pull Request
By default in Github/Gitlab the owner is the only one that has write rights. All other users have read rights so they can clone and fork. Forking in github will give you access to a writable entire repository.
Your own projects or projects where you where added as a collaborator.
Pull requests are a way that allows a forker to contribute back to the original repository. After you make some changes in a place you are allowed to write (repository or branch) you may ask for an accept of a merge: that is the pull request. The owner is informed and can make a decision to accept or reject your pull request. The name clarifies this: you cannot make a push so you ask the owner to pull from your branch/repository. See more about it:
- git - https://git-scm.com/docs/git-request-pull
- gitlab - https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html
- github - https://help.github.com/articles/about-pull-requests/
- bitbucket - https://www.atlassian.com/git/tutorials/making-a-pull-request
Flow Practices - http://nvie.com/posts/a-successful-git-branching-model/
- cheatsheet file lifecycle
- patterns
- authorization patterns
- with pull-requests
- as collaborators
- authorization patterns
- some useful commands
- store password in shell session
- linux:
git config --global credential.helper store
- windows:
git config --global credential.helper wincred
- linux:
- fetching everything including deletion on remote repository:
git fetch --prune
- pushing stuff (including deleting from remote) - https://stackoverflow.com/questions/5480258/how-to-delete-a-git-remote-tag. By omitting the source ref (the part before the colon), you push 'nothing' to the destination, deleting the ref on the remote end.
git push where-to-push source-ref:destination-ref
- delete branch (see https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote)
- from local repository
git branch -d the-local-branch
- from remote repository
git push origin :the-remote-branch
- from local repository
- add remote repo
git remote add new-repo-name http://server.org/.../new-remote-repo.git
- configure local repo as remote
git config --unset core.bare
git config receive.denyCurrentBranch updateInstead
- merging but ignoring any proposed change:
git merge origin/branch-to-ignore -s ours
- store password in shell session
-
others
git add *App.java git add *AppTest.java git add -A git add .gitignore git add App.java git add README.md git branch -a git checkout -b user/costin git checkout -b user/costin-madalin git checkout -b user/costin-ship3 git checkout -b user/costin-ship3b git checkout master git checkout user-Andrei git checkout user-Gabi git checkout user-Gabriel git checkout user-Lucian git checkout user-Madalin git checkout user-Stefan git checkout user-Victor git checkout user-Victor\ git checkout user/costin-ship3 git clone https://github.com/raisercostin/dcsi.git git clone https://github.com/raisercostin/dcsi.git ship2 git clone https://github.com/raisercostin/dcsi.git ship3 git commit git commit -am "add backlog" git commit -am "restructure/refactor" git commit -m "read users" git commit -m "refactored" git config --global credential.helper wincred git config --global user.email "[email protected]" git config --global user.name "raisercostin" git fetch git merge user/costin git merge user/costin-ship3 git merge user/costin-ship3b git pull git push git push --set-upstream origin user/costin-madalin git push --set-upstream origin user/costin-ship3 git push --set-upstream origin user/costin-ship3b git push --set-upstream origin user/costin-ship3c git push --set-upstream origin user/costin git status mvn compile mvn eclipse:eclipse mvn eclipse:eclipse -DdownloadSources mvn test git config --global core.autocrlf false git config --global log.date iso8601
-
github badges - https://shields.io/
- High level git practices
- gitflow - https://datasift.github.io/gitflow/index.html
- cheatsheet - https://danielkummer.github.io/git-flow-cheatsheet
- common sense average topics - http://think-like-a-git.net/sections/experimenting-with-git/references-make-commits-reachable.html
-
List all tags that point to a commit
git tag --points-at f96e7cadce8eda56b037b10a31fbd3815eaa8b3f|xargs git tag -d
-
Delete a set of tags from console
xargs git tag -d <&1
-
Get history for a file or files
See- https://stackoverflow.com/questions/7375528/how-to-extract-one-file-with-commit-history-from-a-git-repo-with-index-filter
- http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
git read-tree --empty git reset $GIT_COMMIT -- $your $files $here ' \ -- --all -- $your $files $here
-
print last commit number:
git log --oneline | wc -l
Ref: https://stackoverflow.com/a/21607276/9337419 -
print last commit short SHA:
git rev-parse --short HEAD
Ref: https://stackoverflow.com/a/5694416/9337419 -
print last commit date and time:
git log -1 --date=format:%Y_%m_%d-%H_%M_%S --pretty=format:%cd
Ref: here and here
brew install git
-
What kind of commits exists?