Link to home
Start Free TrialLog in
Avatar of thready
thready

asked on

first few commands for git?

Hi Experts,

I just did a git svn clone command from my svn repository.  I then worked a bit on the code and have some changes locally that I would like to start another git branch for, before adding these changed files to the git branch.  Could you help me with:
1-  command to create the new branch (considering that I have local mods after initial clone)
2-  add the modified files (since the initial clone)
3-  commit to the branch
4-  revert to normal svn branch.

Thank you very much!
Mike
Avatar of thready
thready

ASKER

I tried the git extensions for explorer - I tried "Create branch" and I get an error that says:

The following untracked working tree files would be overwritten by checkout (with a whole bunch of files).

Why would they be overwritten?
Avatar of evilrix
1-  command to create the new branch (considering that I have local mods after initial clone)

Heh. The general idea is you back the branch first :)

First of all commit any changes to your current (master?) branch

git commit -am "some message"

Then create and checkout your new branch
git checkout -b <branchname>

Your new branch will now be in sync with the previous branch. You can now return back to the previous (master?) branch and reset it back to the original pre-commit state and your new branch will have all the changes.

git checkout <oldbranch>
git reset --hard HEAD^

2-  add the modified files (since the initial clone)

To add all the new files just do

git add .

To add a specific file

git add <filepath>

3-  commit to the branch

git commit -am "commit message"

4-  revert to normal svn branch.

If you mean revert back to the state that reflects the svn repo but the way you'd normally do this is to reset back to the origin/<branch> tag. Assuming you are in master of a tracking branch and you want to reset back to the remote master state you'd do this...

git reset --hard origin/master

Not sure if that will work from an svn repo though as I don't think a direct clone counts as a tracking branch. If that isn't the case then you could look at the git log and find the revision id you want to revert to, something like...

git log

find the revision id and then

git reset --hard <revision-id>
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thready

ASKER

Thanks a lot - I'm about to start using it finally.  My fingers are crossed!  :o)
Heh... good luck -- I doubt you'll ever consider using SVN again once you've started using Git in anger. I never could!
Avatar of thready

ASKER

thanks evilrix - I have another question that I think you'd get super easy points with if you're interested:

https://www.experts-exchange.com/questions/27308409/git-cloned-svn-did-some-work-with-svn-now-want-to-update.html?anchorAnswerId=36538575#a36538575