Send specific branch with Git to Github

2

How can I send a specific branch to Github through Git?

I am creating a project to learn how to use Gulp and its plugins, and in it I created a folder with the source code, called src and a folder containing the minified files, CSS sheets processed and so on, called build . I tried to create a branch in Git called deploy and add only the build files in that branch and then make pull to the repository, but I can not just send this folder.

In the various tests I've done, sometimes the whole project goes, with the folder src , sometimes another remote branch is created in the repository ..

Do you have any such organizing tips for projects with task runners?

    
asked by anonymous 02.04.2016 / 18:37

2 answers

2

Git was not meant to be used as you are thinking. If you store the build generated by your code it makes more sense to have another repository just for the build. Or keep a subfolder called build that is always versioned along with the code that generated that build.

In my opinion versioning the build does not make much sense. Because you can always generate the build from a given git commit. I would put my build just as a file to be published to the server in the middle of the deploy pipeline.

    
02.04.2016 / 20:35
1

When you already have your empty repository in github, you can get the reference in two ways.

  • Cloning the repository

In this way, you use the url to clone (download) the repository to your computer using the git clone.

$ git clone http://github.com/<user>/<repository>.git <nome da pasta>
  • Starting a git project (I believe it's your case)

You should start your project folder and refer to your repository in github.

$ cd <pasta do projeto>
$ git init
$ git add <pasta que deseja adicionar ao repositório>
$ git commit -m "comentário"
$ git remote add origin http://github.com/<user>/<repository>.git
$ git push origin master

If you do not accept git push origin master , this may be because files already exist in your repository. Then the pull should be done before sending the new files.

$ git pull origin master
$ git push origin master

With the second method, you can choose which files and folders to upload to your repository in github.

    
02.04.2016 / 20:24