Git commands to initial, add and commit files

 Author: Shengtao Zhou       Created: 4/6/2019 6:17:31 AM       Modified: 6/23/2019 2:46:18 AM   More...
When you add a huge amount of files to git, you can't really use Git UI tools, like "Git GUI", because it has 5000 files limits for each commit. Here's the command lines that should be used to initial Git repository and add all files:
Open command line, change current directory to the folder you want to create the repository. Run the following commands:

1) Init local repository

git init

2) Add all files

git add --all

3) Commit local repository

git commit -am <commit message>

4) Create a remote repository in github.com, then link remote repository to local repository

git remote add origin https://github.com/user/repo.git

5) Push local repository to remote repository

git push -u origin master

6) Pull from remote branch

If your local repository version is behind from the version in remote repository, push command will fail. So you need run following command first then push again.
git pull <remote repository url> <branch name>

7) Ignore files

Some files you may not want to checkin to Git, you can add them to an ignore file list.

8) Rename local and remote branches

Checkout local branch:

git checkout <local branch name>

Rename local branch:

git branch -m <new local branch name>

Push change to a new remote branch:

git push origin -u <new remote branch name>

Login to github, confirm new remote branch is created.

Delete old remote branch:

git push origin --delete <old remote branch>

For the best practice, your old local branch and old remote branch should have the same name, the same with your new local branch and new remote branch.


More...          Back to List          

(Please enter you comments between 100 to 2000 characters. Thanks for your contribution.) 

         Created:       Modified: 

Editing a comment

       (Please enter you comments between 100 to 2000 characters. Please login before edit comment.) 

div class="col-md-2">