cd /Users/nathan/myProject
git init
git add .
git commit -m "initial commit"
ssh -p 8022 git@colossus.biggerplanet.net
cd /Users/git/Repositories
mkdir myProject.git && cd myProject.git
git --bare init
exit
git remote add origin ssh://git@yoursecret.domain.com:8022/Users/git/Repositories/myProject.git
git push origin master
Clone remote repository:
git clone ssh://git@yoursecret.domain.com:8022/Users/git/Repositories/myProject.git
git add .
git commit -a
echo ".DS_Store">> ~/.gitignore
git config --global core.excludesfile ~/.gitignore
git branch experimental
git checkout -b experimental
git branch
make sure you commit your first branch before you go crazy with new branch!
git checkout experimental
git commit -a
git checkout master
git merge experimental
git diff
or to use filemerge (which should be set up it .gitconfig)
git mergetool
git branch -d experimental
If a branch has changes that have not been merged into your current branch, this will complain. If you're certain you want to delete the branch anyway, use capital D flag -D instead.
???
git remote -v
git remote rename origin destination
mkdir mysubmoduledir
cd mysubmoduledir
git init
make files in submodule
git commit -m "initial commit for mysubmodule"
cd ..
git submodule add mysubmoduledir mysubmodule
git commit -m "added submodule mysubmodule"
git clone cloned
cd cloned
git submodule init
git submodule update
Always publish the submodule change before publishing the change to the superproject that references
cd mysubmoduledir
[update files]
git commit -am "changes to mysubmodule"
git push
cd ..
git commit -am "updated mysubmodule"
git push
Pulling submodule changes
git pull origin master
git submodule update
If you get "fatal: reference is not a tree" error, you may not have pushed the commit of the submodule. Go to the "source" submodule, commit and push the submodule, then commit and push the parent repository, then try "git pull origin master," and "git submodule update" again on the "destination" parent repository.
git update-index --assume-unchanged dir-im-removing/
or a specific file
git update-index --assume-unchanged path/to/file.txt
git reset HEAD dir-im-removing/
git rm --cached -r dir-im-removing/
or for a file
git rm --cached path/to/file.txt
git commit -a -m “any changes” commit any changes you've made
git checkout -b temp create a new branch at current head
git checkout master checkout master (or whatever branch you want to be on)
git merge temp merge with the temp branch you made with your changes
git branch -d temp delete the temp branch
(if setting git config per instructions doesn't work)
... then add the following parameters to your ~/.bashrc file and source it with . ~/.bashrc (or relogin, alternatively):
export GIT_AUTHOR_NAME="Nathan Lamont"
export GIT_COMMITTER_NAME="Nathan Lamont"
See http://stackoverflow.com/questions/2155887/git-submodule-head-reference-is-not-a-tree-error
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
TextMate as the default editor:gitgit config --global core.editor "mate -w"
Opendiff (FileMerge) to resolve merge conflicts:
git config --global merge.tool opendiff
git checkout <branch> -- <path>
E.g.
git checkout develop -- foo.json
git diff <revision_1>:<file_1> <revision_2>:<file_2>
Between branches:
git diff mybranch master -- myfile.cs
git clean -f -d
Omit -d to exclude directories from the operation.
git branch -v
git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(authorname) %(refname:short)'
git diff -- . ':!*.md'
# additional types can be listed
git diff -- . ':!*.md' ':!*.foo*'
New release? Add a tag.
# add a tag
git tag -a v1.0.0 -m "Initial release"
# push current branch with tag
git push origin master --tags
# or push just the tag
git push origin v1.0.0
# list tags
git tag
## GitHub
Have an existing project and want to make it into a GitHub repo?
Make the repo in github then:
```shell
git remote add origin git@github.com:beepy/my-new-project.git
git push -u -f origin main