1

We do not use git for version control, We just use to to backup our projects, So we have A company folder , then each developer uploads his own project , to the tree is like

Company-Project(Main Folder ) -Dev1 Poject -Dev2 Project -Dev3 Project 

I am dev4 , I need to add my project here. When I push , git wont allow me because I do not have work which is already there. I can not clone / pull the master branch as it is too heavy like 5 GB.

Any help ? Please Explain your reason if you are downvoting.

3
  • Can you create a new branch? git branch new-branch git add --all git commit -m "stuff" Commented Apr 4, 2018 at 7:15
  • Git does not push files or folders. Git pushes commits. Each commit has files—specifically, a complete snapshot of all files. You could make a series of commits that has only dev4/* files but anyone checking them out will find that all the dev1/*, dev2/*, and dev3/* files are removed, because your snapshots—your commits—say "don't have any of those files now; have only dev4/* files now". Commented Apr 4, 2018 at 14:26
  • Has your problem been solved yet? Commented Apr 10, 2018 at 7:05

3 Answers 3

1

follow the following steps in your root directory :

git init git checkout -b dev4 git remote add <remotename> <git url> git add . git commit -m "commit message" git push <remotename> dev4 
Sign up to request clarification or add additional context in comments.

2 Comments

error: pathspec 'dev4' did not match any file(s) known to git.
@PankajKushwaha: Try it again with the updated example.
0

It seems the company folder and the folders for different developers (Dev1, Dev2 and Dev2) are manage in the master branch. And you need to add the folder Dev4 in the git repo master branch too.

If it’s your situation, there are two options you can follow:

Option 1: shallow clone the git repo, and commit your changes.

To push your local changes to remote repo, you need and local git repo. You can shallow clone with the latest commit, and then push your changes to the remote repo. Detail commands as below:

git clone <URL> --depth=1 cd reponame #Copy your Dev4 folder in the local repo git add . git commit -m 'commit dev4 in git' git push 

Option 2: upload Dev4 folder directly if the remote repo supports

If your remote repo hosted in the 3rd-party like github, VSTS etc, then you can upload the files/folders from your local machine to the remote repo directly.

Comments

0

I could push a new branch without cloning/pulling whole project. I get the code from jekyll-deploy-action project.

In your case you can do it as below:

cd dev4 rm -rf .git git init --initial-branch=main git remote add origin <git url> git add . git commit -m 'commit dev4 in git' git push --force <git url> main:<new branch name> 

The respond will look like this:

Initialized empty Git repository in dev4/.git/ remote: remote: Create a pull request for '<new branch name>' remote: <git url>/pull/new/<new branch name> remote: To <git url> * [new branch] main -> <new branch name> 

You may need git authorization and TOKEN.
Here is the link to the code.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.