This is just a collection of the notes I have jotted down for myself as I learned how to use Git. I have tried to make sure they are valid, and that the language is understandable, though not necessarily proper 'Git Speak'. I don't think anything is catastrophically wrong, but please don't rely on them for a production machine, or anything you haven't got backed up.
If something really bad happens, feel free to visit my Feedback page and give me a piece of your mind. I won't promise I'll know what happened, I am a newbie myself, but I'll at least grieve with you.
For any of you Git gurus out there, I hope you'll let me know if I'm doing bad things. Any help is appreciated.
mkdir <repo_dir>
cd <repo_dir>
git init
git add .
git commit -m "comment"
git init --bare --shared
cd <repo directory>
git remote rm origin
git remote add origin <path to the bare repository>
git push origin master
git clone <path to bare repo>
git add .
git commit -m "comment"
git push
git fetch
git pull
fetches and merges.
git diff ... <temp fetch branch>
git checkout <temp fetch branch>
git checkout <main branch>
git merge <temp fetch repo>
cat newfile
This is the second line from j
This is the third line from j
<<<<<<< HEAD
This is the forth line from d
=======
This is the forth line from j - This conflicts with d!
>>>>>>> FETCH_HEAD
git init <repo_name>
cd <repo_name>
echo "Hello World" > <file_name>
git add .
git commit -m "Created Hello World file <file_name>"
git checkout -b <new_branch>
echo "howdy right back at you" >> <file_name>
git add .
git commit -m "Answered Hello World in <file_name>"
git checkout master
git merge <new_branch>
git checkout
you can copy specific files from a repo or branch.
git checkout
to copy
the remote file into your local repo and replace your local version.
git checkout <repo or branch> <path to file>
git commit -m "Fixed conflict by copying remote file over local file"
.git/config
, add or edit a [remote "<repo shortcut>"]
section for the remote you want to
configure fetch or push for.
[remote "<shortcut name>"] url = jim@192.168.1.10:/tmp/test_repo3 fetch = +refs/heads/<remote branch>:refs/remotes/<remote repo name>/<temp branch on local> push = +refs/heads/<local branch>:refs/remotes/<local repo name>/<temp branch on remote>
git fetch
or git push
to only fetch or push one branch
and not the default of all the branches on a repo.
git fetch <shortcut name>
or git push <repo shortcut>
remotes/<repo name>/<temp branch>
.
git merge remotes/<repo name>/<temp branch>
git branch -a
git add .
it actually doesn't touch the deleted files. Do a
git status
after committing and you will see that the deleted files still listed.git rm <filename>
git add -A
'Writing and photography define the present by interpreting the past'
For help using this site, please click Help. Thanks, Jim.
©2012 Jim McCullough Page last updated: 2012-06-13