Hello,
I often need to develop stuff on the road, with no internet/network connection. I am only a single developer, so until now I simply had a SVN repository on my machine and did a checkout on my laptop when I went away. Problem: That gives me no Source Control on the road.
So I tried out changing to git, which seems to do what I want, but I am not sure I understand properly how it's supposed to be used in my setup.
Essentially:
- Created a repository on \myserver\share\project using
git init
- Cloned that repository to machine 1 using
git clone
- Cloned that repository to machine 2 using
git clone
- Worked on machine 2, using
git commit
to commit any changes to my local repository - Finally used
git push
to push all changes back to \myserver\share\prohect - Used
git pull
on machine 1 to get newest changes from \myserver\share\project
That works, but the git push
command gives me a warning saying that pushing the checked-out branch is not supported as it may confuse the index. Now, I'm confused, because the message was also written in a serious tone, which means that I should possibly honor it (and indeed, gitk shows that I now have two branches: master and remotes/origin/master), but I do not fully understand the terminology yet.
What would be the correct steps in my situation?
- I will only ever work on machine 1 OR machine 2, never on both
- I intend to use branching as a way to have a separate branch for bugfixes/tests (just like in the usual way), but not as a way to have multiple developers
- I really mainly want to use it as an alternative to rsync my SVN.
Edit: There are two oddities. The first one is if I simply change a file, it says "Changed but not updated". which is weird:
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: myproject/Readme.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
The second message is the one that I think is the culprit, the output of git push:
warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated. This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning: 'nothing' : Do not push anything
warning: 'matching' : Push all matching branches (default)
warning: 'tracking' : Push the current branch to whatever it is tracking
warning: 'current' : Push the current branch
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 333 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning:
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning:
warning: To squelch this message, you can set it to 'warn'.
warning:
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
To file:///\\myserver\share\project
129649b..1f4b957 master -> master
So it tells me that "pushing into the current branch" is not recommended, but I don't really get what the proper way of doing this is.