Whoops, I am remiss, and forgot a few things:
- "origin" is what is known as a "remote". This might be a
colleague's computer, or it might be a central server (I only have
experience with the latter). By default, the remote is named "origin".
So, when you're dealing with remote branches that live on "origin",
they will be prefixed with "origin/"
- a branch in your local repo ("master") is independant of the branch
on origin ("origin/master"). This makes sense, because you can commit
to your local branch without affecting others, and vice-versa. But, it
was non-obvious for me.
- because of this, when you update your local repo (git merge),
you're performing the exact same operation as merging a branch into
your branch (because you are). This includes nastiness like merge
conflicts, but also good things like updating history.
- adding a file (git add) does not have the same semantics as it does
in subversion. Specifically, adding a file only marks it for staging.
That is, it says "next time I commit, include this file". Already
existing files still need to be added when you want to commit their
changes. Conversely, if you don't want to commit certain files, you
can just not add them.
- Other useful git commands:
git diff #show uncommitted changes
git diff --cached #show staged, but uncommitted changes (i.e., only
what you've added)
git blame path/to/file #see who done what when
git log #review older commits
git reset path/to/file #un-add a file
git reset --hard #nuke your changes from orbit (make everything clean again)
On Wed, Apr 18, 2012 at 2:00 PM, Mike Caron <[email protected]> wrote:
> The thing to remember about git is that it's all about branches. You
> are always on a branch, usually called master (but that varies, of
> course). So, I will use master as the branch name below.
>
> To update your repo, you need to do this:
>
> git fetch #pulls changes from "origin"
> git merge origin/master #updates working copy
>
> To commit changes, you just need to do this:
>
> git add path/to/file #adds a file
> git add -u #adds all changed files
> git add -a #adds all non-ignored files
> git commit -m "your message goes here"
>
> (obviously, pick whatever add command is most appropriate)
>
> Lastly, to push your changes back to origin, just do this:
>
> git push origin master
>
> (if your branch is not up to date, you will need to refresh it as above)
>
> That's all you need to know to get started. However, I strongly
> suggest you learn git's branching mechanics, because they are really
> powerful and really useful. At my work, we use a branch per
> ticket/bugfix, and it works beautifully.
>
> Sent from my iPad
>
> On 2012-04-18, at 12:56 PM, James Paige <[email protected]> wrote:
>
>> I figure if I am ever going to learn to use git, I need to learn how to
>> replicate my existing svn usgae patterns with git. I have been told many
>> times that git's functionality is a superset of svn's so this should be
>> no problem.
>>
>> My trouble is that every tutorial I can find, even the ones that are
>> supposedly intended for recent converts from svn seem to want me to jump
>> right in to gits more advanced features, and discard my old workflows.
>>
>> I would much rather first get used to using git exactly thew same way I
>> use svn, and then when I am confortable with that, I can start learning
>> the new fancy things that make git special.
>>
>> I have two different workflows for svn repositories
>>
>> 1) I have read only access, and I am not changing anything. All I want
>> to do is keep my local copy up-to-date with upstream. With svn I just
>> do:
>>
>> svn cleanup
>> svn update
>>
>> in a cron job, and all is happy. However, I am not clear on how to do
>> this in git. I assume it is simple, but I get confused when I search for
>> "git equivalent for svn update" and every single search result tells me
>> something different, and none of them are trying to do the uber-simple
>> case that I care about anyway.
>>
>> 2) Committing my local changes back to a remote server. This is what I
>> would want to do if I was working on the ohrrpgce using git. I know I
>> that local branches are a big deal with git, and that disconnected
>> operation without an internet connection is a big deal with git, but for
>> my purposes I want to treat a centralized repsitory on a server as the
>> master, and use it to sync any assorted workstations I might happen to
>> be sitting in front of at the moment.
>>
>> ---
>> James, Curious
>> _______________________________________________
>> Ohrrpgce mailing list
>> [email protected]
>> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
--
Mike Caron
Tale of the Cave
http://taleotc.com
_______________________________________________
Ohrrpgce mailing list
[email protected]
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org