0% found this document useful (0 votes)
10 views13 pages

GiT RW

The document provides a comprehensive guide on project management using Git, covering essential commands for setting up a repository, managing branches, stashing changes, and collaborating with remote repositories. Key commands include initializing a repository, creating and merging branches, and cloning remote repositories. It also details the process of stashing changes and applying them across branches, ensuring effective version control and collaboration in software development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views13 pages

GiT RW

The document provides a comprehensive guide on project management using Git, covering essential commands for setting up a repository, managing branches, stashing changes, and collaborating with remote repositories. Key commands include initializing a repository, creating and merging branches, and cloning remote repositories. It also details the process of stashing changes and applying them across branches, ensuring effective version control and collaboration in software development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

PROJECT MANAGEMENT WITH GIT

1. Setting Up and Basic Commands :


 Initialize a new Git repository in a directory. Create a new file and
add it to the staging area and commit the changes with an appropriate
commit message.
 mkdir Git : Creates a folder/directory in the present working
directory.
 cd Git : Changes the directory to the git folder which was created.
 git init : Initializes a empty git repository.
 vi file.c : Creates a empty file of c extension in the current directory.
 git add . / git add <file name> : Stage the file with add . or add <file name>.
add will stage the whole files in the current directory and are ready to commit.
 git commit : Commit the file with appropriate commit message.
 git status  It checks the status, like on which branch we are and is there any
changes made which are not committed .
If no any other changes has been made after recent commit, it displays the
working tree is clean.
 git log  Displays all the history of commits with commit messages along
with the author name and email.
 Every commits has a unique commit ID.
COMMANDS:
2. Creating and Managing Branches :
 Create a new branch named "feature-branch." Switch to the "master"
branch. Merge the "feature-branch" into "master.
Step 1:

 git branch feature-branch  This will create a new branch of the master branch
in which the contents and files are copied from the master branch.
 git branch  This command will show all the branches which we have made
and the current branch will be in green colour.
Step 2:

 git checkout <branch name>  It is used to switch one branch to other


branch,here we are moving from branch master to the feature-branch.

 And also we can edited the file (file.txt).


Step 3:

 Here in the feature-branch we staged the file and commit with appropriate
message that “1st line of FB (v1)”.
 So here the file has been changed ,but in the master branch it will be as it is
until we merge the feature-branch with the master branch.
Step 4:

 For merging the file to the master branch we first need to move to the
main/master branch using “git checkout master” command.
 Then we can merge the branch with “git merge feature-branch” command.
 So ,now the files will be merged ,the changes or the edits in the feature-branch
will be merged.
Step 5:

 git log  Here the history of the commits will be visible.

3. Creating and Managing Branches :


 Write the commands to stash your changes, switch
branches, and then apply the stashed changes.
Step 1:

 Moving to the feature branch and have made changes in the


file(file.txt) using the commands git checkout feature-branch
and vi file.txt for changing the branch and editing the file
respectively.
 Here we have not staged and committed the changes in the

file(file.txt).

Step 2:

 In this step we have stashed the changes which have been


made in the file.txt file in the feature-branch.
 Here we have not added/staged the file and committed the
changes.
 The changes will be saved in the branch without the
committing the changes.
 The command used for stashing the changes is “git stash”
Step 3:

 Before applying the changes made in the feature-branch,first we need move to


the master branch.
 Then in the master branch we applied the stash using “git stash apply” where
changes made in the feature-branch.
 After applying the stash to the master. It will give us a message saying that the
applied stash is not staged and committed in the master branch.

Step 4:

 After stashing we check status using “git status” ,there it shows that the
file(file.txt) is modified but not staged yet.

 After staging, if we check the status again it shows that changes to be


committed yet
 Committed with appropriate message that “FB code & Stash code”

 After committing the changes we can see the log of the repository.
4. Collaboration and Remote Repositories
:
 Clone a remote Git repository to your local machine.
Step1:
 To clone a remote git repository ,first we need to open the github.com and open
any of the account on the github.com
 After that we have chosen the repository which we want to clone into our local
machine.
 After choosing the repository , in that repository we clicked on the green
button “code” ,which open a drop down list of links in that ,we copied the
“HTTPS” link from that. https://github.com/Abhishek-4949/Demo.git
Step2:
 In the second step we need to open our git bash and in some directory where
you need to clone the remote repository we need to move to that location using
“cd <path name> “ command.
 Here we want to copy the repository to the folder clone in the c so we moved to
that location
 git clone https://github.com/Abhishek-4949/Demo.git  this command will
copy the repository from remote to the local machine in the working directory.
 you can see above the “Demo” repository is successfully copied in the clone
directory/folder.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy