- This topic is empty.
-
AuthorPosts
-
December 21, 2013 at 11:23 pm #158967nixnerdParticipant
Today, I attempted to create a new branch for a project.
I then attempted to pull ONLY that branch onto a remote server. What happened from there is me messing a lot of stuff up… FAST.
I managed to somehow replace my master branch with the new branch in another directory on the remote server, so I tried to fix it and delete the branch, only to find out I had not just deleted the branch but deleted the actual files on my local machine. I was able to retrieve it by finding some copy Git saves… I just got in big trouble really fast.
What’s amazing is… I looked at my terminal history and was shocked that I did that much damage with the simple commands I ran. Crazy.
Suffice it to say… I REALLY don’t understand how to branch properly. Can someone please give me some material to educate my ignorant ass?
December 21, 2013 at 11:48 pm #158969__ParticipantWell, what you might have missed is that, when you switch branches, git changes your “working tree” to match what that branch should look like. It literally changes all of the files in your project. They are not gone. When you switch back to master, for example, the files will be changed back to what they were when you last committed to master.
To address your specific problem of pulling a branch to your remote server, you need to [create and] switch to that branch on the remote first, then pull it from your local machine. Then your remote can work on it, merge it, or switch back to master and ignore the branch if desired.
Have you looked at the git branch examples?
December 22, 2013 at 5:07 pm #158990__ParticipantUnless you deleted the repo, you should be able to revert it. But I couldn’t be sure how, without knowing what you did and what state the tree was in.
If I understand your first post correctly, you wanted to:
-
create a new branch locally
-
work on it and commit
-
save the new branch to your remote (i.e., not merge with the remote master)
correct?
…create and checkout new branch
$ git checkout -b myNewBranch
…work on new branch
$ git add ./my/new/files.etc $ git commit -am 'my new files'
…push to myNewBranch on remote (will be created if it doesn’t exist yet)
$ git push <remote-name> myNewBranch
December 23, 2013 at 12:50 pm #159030KuzyoParticipantI’m too have one question on git pull requests.
Here is my situation – I made changes on
for-example-branch
and send pull requests to remote repository, my pull request don’t merge (because it was outdated), author of repository made changes to update my pull request – does it updated myfor-example-branch
on my PC or shoud I makegit pull
to recieve the changes?Thanks for reply.
December 23, 2013 at 9:08 pm #159045__ParticipantYou won’t get the changes unless you pull them.
-
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.