Use multiple git accounts on one machine (link):
USE git clone git@github-COMPANY:mshahriarinia/Golang.git
setup GPG with git Install GPGTools on mac find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \; git diff master --name-only Diffs for the past two three commits
Stop tracking a file: Resume tracking the file
$ git log -p --color $ git branch -av # to list all branches Setup git
clone a repository and its branches
Branching best practices http://nvie.com/posts/a-successful-git-branching-model/
Tag
Setup kdiff3 as mergetool in Mac
git config --global --add merge.tool kdiff3git config --global --add mergetool.kdiff3.path "/Applications/kdiff3.app/Contents/MacOS/kdiff3"git config --global --add mergetool.kdiff3.trustExitCode falsegit config --global --add diff.guitool kdiff3git config --global --add difftool.kdiff3.path "/Applications/kdiff3.app/Contents/MacOS/kdiff3"git config --global --add difftool.kdiff3.trustExitCode false To pull out a single file out of an old commit: $ git log # determine commit sha-1 $ git ls-tree SHA-1_OF_THE_COMMIT $ git cat-file -p SHA-1_OF_THE_SPECIFIC_FILE $ git log -p --color $ git branch -av # to list all branches git push -f origin master git fetch upstream; git checkout master; git rebase upstream/master git rebase --continue; git rebase --skip; git mergetool Link to file or its line numbers: you only need 4 characters of the commit SHA in the URL.. it figures it out. i usually truncate to 7ish characters. Nice: github.com/jquery/jquery/blob/27291ff/src/css.js#L171-185 clone a repository
$ gitk shows the commits tree from different branches $ git diff --name-only # Get list of all modified files: $ git pull #get latest files and updates $ git remote -v # Address of the repository Branching best practices http://nvie.com/posts/a-successful-git-branching-model/ $ git init #make a repository Tags$ git tag -a tagTitle -m "Description." # Use tags: http://www.rockstarprogrammer.org/post/2008/oct/16/git-tag-does-wrong-thing-default/ $ git push --tagsYou can download the whole snapshot of the project regarding a specific tag here: https://github.com/mshahriarinia/gatordsr/tags OR $ git add -A # Git add all files modified, deleted, and untracked
Undo to a specific version
In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like: If you've rebased your branch onto upstream/master you may need to force the push in order to push it to your own forked repository on GitHub. You'd do that with: $ git push -f origin master # You only need to use the -f the first time after you've rebased. OR $ git merge --no-ff upstream/master # If you don't want to rewrite the history of your master branch, (for example because other people may have cloned it)
[$git pull does a $git fetch followed by a $git merge.] You can do a git fetch at any time to update your local copy of a remote branch. This operation never changes any of your own branches and is safe to do without changing your working copy. Open Source Contributionusername mshahriarinia is going to contribite to the repository https://github.com/cegme/gatordsr
$ git clone git clone https://github.com/mshahriarinia/gatordsr.git To eclipsify the scala project that uses sbt: $ sbt eclipse 3. Set up the remotes
# Assigns the original repository to a remote called "upstream" . add a remote for the main repo that you forked
$ git push origin master Don't commit your changes to your local master branch. As the project evolves in it's upstream location(repository) (the actual owner's URL), your mster's branch will stay lagged and you will have difficulty checking what's going on with the project up-to-date.
$ git push origin fix_for_this_or_that Branching allows you to build new features or test out ideas without putting your main project at risk. In git, branch is a sort of bookmark that references the last commit made in the branch. This makes branches very small and easy to work with. Branches are pretty easy to work with and will save you a lot of headaches, especially when working with multiple people. To create a branch and begin working in it, run these commands:
To switch between branches
--no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. $ git branch -d mybranch # Deletes the "mybranch" branch
$ git rebase --continue if not solved $ git mergetool$ git merge --no-ff new_branch$ git merge --no-ff upstream/master # merge back with the repository you got the code from
$ git branch --merged # Shows branches that are all merged in to your current branch$ git branch --no-merged $ # Shows branches that are not merged in to your current branch
$ git fetch upstream; git checkout master; git rebase upstream/master if everything is ok this will go through hands-down. if there are merge conflicts you will be prompted, then $ git rebase --continue; git rebase --skip; git mergetool also every once in a while execute the following command to get rid of the .orig files that would appear after a merge find . -name "*.orig" -print0 | xargs -0 rm
|