Create Git branch - GitHub

 Steps to create a branch and push files:

1. first clone master branch 

git clone repo_url

2. create branch 

git branch branch_name

3. push branch to remote

git push -u origin branch_name

Here your branch will be visible in branches, next you want to add on something in your branch and push to remote. Let's move to step 4>

4. Now to start work on your own branch, first you need to switch to your branch

git checkout mnt_code-revamp-v1

5. to check your current working branch, it will show you all files and mark * on current one

git branch -a

git branch --show-current (Git 2.22 and above)

5.1 Add data/ files to local repository and then push to git branch

Add file : git add . 

commit those changes: git commit -m requirements.txt

Push file to branch: git push requirements.txt

5.2 Add folder to local repository and then push to git branch

git add *

git commit .....pop for enter a message ....write message and hit Esc>:wq! Enter

git status

5.3 Add all changes to git 

git add -a / git commit / git push


How to handle LF and CRLF error:

 LF will be replaced by CRLF in git 

Windows : CRLF(Carriage Return & Line Feed charactor )

Unix: LF

Git can handle this by auto-converting CRLF line endings into LF when you add a file to the index, and vice versa when it checks out code onto your file system with below command 

git config --global core.autocrlf true

Turn off the warning: git config --global core.safecrlf false


You should use core.autocrlf input and core.eol input. Or just don't let git change the line endings at all with autocrlf false and get rid of highlighting of crlfs in diffs, etc with core.whitespace cr-at-eol.







References: https://dzone.com/articles/top-20-git-commands-with-examples 

https://stackoverflow.com/questions/9329244/how-to-commit-and-push-all-changes-including-deletes

Comments